PDA

View Full Version : PHP MySQL Form Data not actually posting


peerData
07-31-2009, 07:35 PM
A slight problem, surely something I am over looking, I have read tuts all over to see what I am missing and I am not seeing it...

What I have is form.php and process.php - For those of you that are familure you understand what it does. Anyway when the form is submitted, Process pulls up saying Data has been submitted. When I go to the DB and look to see the information, it actually inserted a new table, BUT, there is no data there... I have even tried to change process.php to chmod 777 (I know unsecure, but for testing purposes) and it still did not work.

Any assistance on this would be much appreciated.

Thank You in Advance,
Mike a.k.a peerData


Below is my code,
// FORM.PHP
<th align="left" valign="top" scope="row"><div align="left">
<form id="form1" name="form1" action="process.php">
<table width="50%" border="0">
<tr>
<th width="37%" height="18" scope="row"><div align="left">Enter Your NickName:</div></th>
<td width="63%"><label>
<input type="text" name="name" id="name" />
</label></td>
</tr>
<tr>
<th height="18" scope="row"><div align="left">Enter Todays Date:</div></th>
<td><label>
<input name="todays_date" type="text" id="todays_date" value="example: July 29, 2009" />
</label></td>
</tr>
<tr>
<th height="18" scope="row"><div align="left">Choose Mon. to Own:</div></th>
<td><label>
<select name="own_month" size="1" id="own_month">
<option value="Jan" selected="selected">January</option>
<option value="Feb">Febuary</option>
<option value="Mar">March</option>
<option value="Apr">April</option>
<option value="May">May</option>
<option value="Jun">June</option>
<option value="Jul">July</option>
<option value="Aug">August</option>
<option value="Sept">September</option>
<option value="Oct">October</option>
<option value="Nov">November</option>
<option value="Dec">December</option>
</select>
</label></td>
</tr>
<tr>
<th height="18" scope="row"><div align="left">Choose Year to Own:</div></th>
<td><label>
<select name="own_year" id="own_year">
<option>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
<option>2014</option>
<option>2015</option>
</select>
</label></td>
</tr>
<tr>
<th height="18" scope="row"><div align="left">Enter your email:</div></th>
<td><label>
<input type="text" name="email" id="email" />
</label></td>
</tr>
</table>
<p>
<label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label>
<label>
<input type="reset" name="Cancel" id="Cancel" value="Cancel" />
</label>


// PROCESS.PHP
<?php
$name=$_POST['name'];
$todays_date=$_POST['todays_date'];
$own_month=$_POST['own_month'];
$own_year=$_POST['own_year'];
$email=$_POST['email'];
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("roomowner") or die(mysql_error());
mysql_query("INSERT INTO `roomowner` VALUES ('$name', '$todays_date', '$own_month', '$own_year', '$email')");
Print "Your information has been successfully added to the database.";
?>

CFMaBiSmAd
07-31-2009, 08:02 PM
Your <form has no method attribute. The default method is GET, so none of your $_POST variables have a value.

Add method="post" to your form tag.

When learning php (or learning anything new in php), developing php code, or debugging php code, set error_reporting to E_ALL and display_errors to ON in your php.ini to get php to help you. The missing $_POST variables would have resulted in errors that would have helped you find the problem.

peerData
07-31-2009, 08:12 PM
THANK YOU!!!. I dont know how I missed that, and I will set php to report the errors. I knew it was something simple and stupid I was missing. Usually that is the case in most problems.

Thank you for taking the time with this.
Mike a.k.a peerData