MySQL Connection


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $con = mysql_connect("localhost", "root", "root");
  2. if (!$con) {
  3. die('Could not connect: ' . mysql_error());
  4. }
  5.  
  6. mysql_select_db("sfcommunity", $con);
  7.  
  8. $sql = "INSERT INTO jos_users_info (FirstName, LastName, Company_name, Email)
  9. VALUES ('$_POST[name]','$_POST[lastname]','$_POST[companyname]','$_POST[email]')";
  10.  
  11. if (!mysql_query($sql, $con)) {
  12. die('Error: ' . mysql_error());
  13. }
  14. mysql_close($con);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.