Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_Post Question

Status
Not open for further replies.

about2flip

Technical User
Nov 21, 2003
31
US
Hi:

I am trying to write a date selected by the user into mysql date column. There are three variables month, day, year.

Here is portion of the code from the script that will insert the data into the DB:

Code:
/ create query
    $query = "INSERT INTO $table_name (shipperorg, pickupdate, origincity, originstate, destcity, deststate, loadtype, equiptype, weight, miles) VALUES ('$_POST[shipperorg]', '$_POST[month,day]', '$_POST[origincity]', '$_POST[originstate]', '$_POST[destcity]', '$_POST[deststate]', '$_POST[loadtype]', '$_POST[equiptype]', '$_POST[weight]', '$_POST[miles]')";

Someone on this forum told me that I could do $_POST[month:day:year]' but that did not work. I also tried commas too.

I am also trying to echo the results using:
Code:
<td><strong>Pick Date: </strong></td>
    <td><? echo "$_POST[month,day]"; ?></td>

I'm only showing month, day because I was doing some test.

Any help is greatly appreciated. THANKS!!!
 
It's hard to say because we can't see what your date column in the database accepts as ok information. However, what you're trying to do is wrong. I would concatenate year, month and day into a single string:
Code:
$query = "INSERT INTO $table_name (shipperorg, pickupdate, origincity, originstate, destcity, deststate, loadtype, equiptype, weight, miles) VALUES ('$_POST[shipperorg]', '" . $_POST['year'] . $_POST['month'] . $_POST['day'] . "', '$_POST[origincity]', '$_POST[originstate]', '$_POST[destcity]', '$_POST[deststate]', '$_POST[loadtype]', '$_POST[equiptype]', '$_POST[weight]', '$_POST[miles]')";
 
If you are submitting a form to the PHP page... and using the method POST... and you have 2 fields named "month" and "day" in that form... then you can echo the values to the page using the following:
Code:
<?
if (isset($_POST['month'])) echo 'Month = '.$_POST['month'];
if (isset($_POST['day'])) echo 'Day = '.$_POST['day'];
?>
Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
If it makes a difference my column for pickupdate in my db is:

Field-pickupdate
Type-varchar
Length-32
Attributes- empty
Null-notnull
default-empty
extra-empty

Thanks.
 
Also BabyJeff, thanks but I a posting using the following:

Code:
<td width="145"><? echo "$_POST[shipperorg]"; ?></td>
  </tr>
  <tr>
    <td><strong>Pick Date: </strong></td>
    <td><? echo "$_POST[date]"; ?></td>
  </tr>
  <tr>
    <td><strong>Origin City: </strong></td>
    <td><? echo "$_POST[origincity]"; ?></td>
  </tr>
  <tr>
    <td><strong>Origin State: </strong></td>
    <td><? echo "$_POST[originstate]"; ?></td>
  </tr>
  <tr>
    <td><strong>Destination City: </strong></td>
    <td><? echo "$_POST[destcity]"; ?></td>
  </tr>
  <tr>
    <td><strong>Destination State: </strong></td>
    <td><? echo "$_POST[deststate]"; ?></td>
  </tr>
  <tr>
    <td><strong>Load Type: </strong></td>
    <td><? echo "$_POST[loadtype]"; ?></td>
  </tr>
  <tr>
    <td><strong>Equipment Type: </strong></td>
    <td><? echo "$_POST[equiptype]"; ?></td>
  </tr>
  <tr>
    <td><strong>Weight</strong></td>
    <td><? echo "$_POST[weight]"; ?></td>
  </tr>
  <tr>
    <td><strong>Miles</strong></td>
    <td><? echo "$_POST[miles]"; ?></td>
  </tr>
 
Thanks. I got it. I appreciate the Help

Code:
<td><? echo "$_POST[month] / $_POST[day] / $_POST[year] "; ?></td>

This is how I got it to show in the confirm page.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top