Trying to write to a MySQL database with a PHP form -


i'm trying simple write database html form, using php.

i've run sql query in database , works perfectly. however, using form doesn't work. i'm not sure why. help? user/pass/db name correct.

<?php if(isset($_post['submit'])) {  $con = mysql_connect("localhost","delives0_ideas","ideas"); if (!$con)   {   die('could not connect: ' . mysql_error());   }  mysql_select_db("delives0_ideas", $con);  mysql_query("insert data (firstname, lastname, email, idea) values ('$_post['firstname']','$_post['lastname']', '$_post['email']', '$_post['idea']')");  //also email besides writing database  mysql_close($con); ?>  <form method="post"> <strong>first name:</strong> <input type="text" name="firstname"/> <br/> <strong>last name:</strong> <input type="text" name="lastname"/> <br/> <strong>email:</strong> <input type="text" name="email"/>  #####put javascript checker valid emails, name@site.com format <br/> <br/> <strong>idea:</strong> <br/> <textarea rows="10" cols="30" name="idea">  hit best shot. </textarea>  <br/> <input name="submit" type="submit" value="submit"/> </form> 

you forgot "action = nameofyourpage.php" inside form markup. , add "or die (mysql_error())" @ end of query check syntax of request.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -