PHP inserts data, insert Save record

Source: Internet
Author: User

<?php
if ($_post[ok])
{
$link _id = mysql_connect ("localhost", "root", "") or Die ("Connection failed");
if ($link _id)
{
Select Database
mysql_select_db ("My_test");
Insert Data SQL statement
$sql = "INSERT into userinfo values ('. $_post[id]." ', ' ". $_post[name]." ', ' ". $_post[gender]." ', '. $_post[age]. "', '". $ _post[regdate]. "')";
Execute SQL statement
$result =mysql_query ($sql);
if ($result)
{
echo "Record has been successfully inserted into <br><a href= ' insert.php ' > Continue insert record </a>";
}
Else
echo "Failed to execute INSERT SQL statement";
Close Database
Mysql_close ($link _id);
}
}
Else
{
?>
<form Method=post action=insert.php>
Number <input type=text name= "id" ><br>
Name <input type=text name= "name" ><br>
Gender <input type=text name= "gender" ><br>
Ages <input type=text name= "age" ><br>
Registration time <input type=text name= "RegDate" ><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type=submit Name=ok value= "Submit" >
</form>
?
}//end if
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.