Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con = mysql_connect("localhost","peter","abc123");
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db("my_db", $con);
- $sql="INSERT INTO Persons (username, password, first_name, last_name, email)
- VALUES
- ('$_POST["username"]','$_POST["password"]','$_POST["first_name"]','$_POST["last_name"]','$_POST["email"]')";
- if (!mysql_query($sql,$con))
- {
- die('Error: ' . mysql_error());
- }
- echo "1 record added";
- mysql_close($con)
- ?>
- <html>
- <body>
- <form action="insert.php" method="post">
- username: <input type="text" name="username" /> <br />
- password: <input type="password" name="password" /> <br />
- Firstname: <input type="text" name="firstname" /> <br />
- Lastname: <input type="text" name="lastname" /> <br />
- email: <input type="text" name="email" /> <br />
- <input type="submit" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement