Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ************************* forms.php***************************************************************
- <html>
- <head>
- <title>AirZooka ftw</title>
- </head>
- <body>
- <form action="test.php" method="post">
- Username: <input type="text" name="username1" value="" /><br />
- <br />
- Password: <input type="password" name="password1" value="" /><br />
- <br />
- Name: <input type="text" name="name" value="" /><br />
- <br />
- Address: <input type="text" name="address" value="" /><br />
- <br />
- Country: <input type="text" name="country" value="" /><br />
- <br />
- Zip Code: <input type="text" name="zip" value="" /><br />
- <br />
- Phone Number: <input type="text" name="phone" value="" /><br />
- <br />
- Email: <input type="text" name="email" value="" />
- <br />
- <input type="submit" />
- </form>
- </body>
- </html>
- *****************************************test.php******************************************************
- <?php
- //defining username, password, and database variables so I can easily change them later.
- $username="root";
- $password="tacotruck";
- $database="form";
- $username1=$_POST['username1'];
- $password1=$_POST['password1'];
- $name=$_POST['name'];
- $address=$_POST['address'];
- $country=$_POST['country'];
- $zip=$_POST['zip'];
- $phone=$_POST['phone'];
- $email=$_POST['email'];
- mysql_connect("localhost", $username, $password) or die("Unable to connect to MySQL.");
- $query = "INSERT INTO test_table (username, password, name, address, country, zip, phone, email)
- VALUES ('$username1','$password1','$name','$address','$country','$zip','$phone','$email')";
- $result = mysql_query($query);
- if (!$result) {
- echo 'An error occured while inserting the data.';
- } else {
- echo 'Success!';
- }
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement