Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>PHP Form</title>
- </head>
- <body>
- <form action="" method="post" name="form1">
- Name: <input type="text" name="username" placeholder="Your name">
- Password: <input type="password" name="password" placeholder="Your password">
- Email: <input type="email" name="email" placeholder="Your email">
- <input type="submit" name="submit" value="Submit!">
- </form>
- <?php
- $dbName="myTest";
- $user="root";
- $pass="";
- $host="localhost";
- $link = mysql_connect($host, $user, $pass);
- if(!$link){
- die('Could not connect: ' . mysql_error());
- }
- $dbselected = mysql_select_db($dbName, $link);
- if(!dbselected){
- die('Can\'t use ' . $dbName . ":" . mysql_error());
- } else{
- echo "Connected successfully";
- }
- 29 $username=$_POST['username'];
- 30 $password=$_POST['password'];
- 31 $email=$_POST['email'];
- $sql = "INSERT INTO myTable (username, password, email) VALUES ('$username', '$password', '$email')";
- if(!mysql_query($sql)){
- die("Error: " . mysql_error());
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement