Jump to content

Php Simple Text Form


driz

Recommended Posts

Hi, I have created a simple form that looks like this:

					<form action=\"admin/new_press_process.php\" method=\"post\">									<fieldset>										<legend>New Press Release</legend>										<ul>								<li>									<label><strong>Title:</strong></label>									<input type=\"text\" name=\"title\" />								</li>												<li>									<label><strong>Body:</strong></label>									<textarea name=\"body\"></textarea>								</li>																<li>									<label><strong>Excerpt:</strong></label>									<textarea name=\"excerpt\"></textarea>								</li>												<li>									<input type=\"submit\" value=\"Submit\" />								</li>											<ul>									</fieldset>								</form>

and the new_press_process.php it submits to, looks like this:

<?php																	$title=$_POST['title'];												$date=date("Y-m-d");												$body=$_POST['body'];												$excerpt=$_POST['excerpt'];												$host='localhost';												$username='u0558234';												$pass='26jun87';												mysql_connect($host,$username,$pass);												mysql_select_db($username);												$query="INSERT INTO news VALUES (NULL,'".$title."','".$date."','".$body."','".$excerpt."')";												$result=mysql_query($query);												if(mysql_affected_rows()==1) {													echo '<p>Details were successfully added</p>';													}												else												{							echo '<p>There was a problem</p>';						}										?>

However it isn't submitting the contents to my database, it just displays the "There was a problem"Any ideas what the problem could be? Thanks.

Link to comment
Share on other sites

Do some basic error handling and debugging, at least.var_dump($_POST) to see what's actually arriving.use isset() to test the values of your POST variables before you go assigning them.check the return values of mysql_connect() and mysql_select_db()Echo your query string to make sure it's formatted correctly.check mysql_error() after you call mysql_query()You've gone through this before. You should know what to look for. If you do all this, and you're still stuck, come back for more ideas.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...