Help - Search - Members - Calendar
Full Version: Posting Data From Form To Database
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
jackosticks
Hey, I am coding a PHP script to take shit from my form and post it to my MySQL database, I was going to steal the code I have already written, but it seems I have lost the files. So please if you would, give me the code for sending shit to an MySQL database, I remember how to Connect, get the form going, and all that crap, just give me the PHP Sql string for sending away, would help greatly, thanks.
jackosticks
miraculously remembered the code, for those coming across this post seeking assistance, here is the code to do it:

CODE
<?php

$email= $_POST['email'];// in this particular instance i was posting from a form

$con = mysql_connect("localhost","youruser","yourpassword");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("yourdatabasename", $con);

mysql_query("INSERT INTO yourtablename(that you wish to insert into) (the columns you sih to insert into, separated by commas)
VALUES ('VALUE','VALUE')");// the values you wish to insert into stated columns(must be respectively)


mysql_close($con);
?>


In this particular instance i was posting from a form, here is the code for my form:
CODE
<form id="form1" name="form1" method="POST" action="post.php">
  <input name="email" type="text" id="email" value="email" size="50" />
  <input type="submit" name="submit" id="submit" value="Submit" />
</form>


Hope this helps any people who come across this ^^,
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.