Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!
I have a little problem with PHP- $_GET/$_POST

First I have a button:
<form action='index.php' method='post'>
<input type='submit' name='show' value='Make a post!'>
</form>

And then in php:
if ($_POST['show'])
{
//echoing out another button with the name, submit

echo "<form action='index.php' method='POST'>
<input type='submit' style='width: 175px;' name='submit' value='post'>
</form>"; //and some text boxes!


And then... This will upload the things that i wrote in some text boxes(which I didn't write here) to mysql:

if ($_POST['submit'])
{
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$date = date("Y-m-d");
$time = date("H:i:S");

 if ($name&&$email&&$message)
 {
 $querypost = mysql_query("INSERT INTO blog VALUES ('','$name','$email','$message','$date','$time')");
  echo "Please wait... <meta http-equiv='refresh' content='2'>";
 }
 else
  echo 'Please fill out all fields';
}

But its not working, and i can't find a reason to why?! The uploading (and everything else) is working when i don't have the "if ($_POST['show'])" .
Thank you!
Posted
Updated 22-Jan-11 5:28am
v4

1 solution

Try using isset lilke this:

if (isset($_POST['submit']))


Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900