Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HTML START ------------------------------------------------------------------------------------------------------->>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Computer World Customer Information</title>
- </head>
- <body>
- <form action="sql_script.php" method="post">
- <fieldset>
- <legend>Enter your information in the form below:</legend>
- <p><label>First Name: <input type="text" name="firstname" size="20" maxlength="40" /></label></p>
- <p><label>Last Name: <input type="text" name="lastname" size="20" maxlength="40" /></label></p>
- <p><label>Address: <input type="text" name="address" size="20" maxlength="40" /></label></p>
- <p><label>City: <input type="text" name="city" size="20" maxlength="40" /></label></p>
- <p><label>State: <input type="text" name="state" size="20" maxlength="40" /></label></p>
- <p><label>Zip Code: <input type="text" name="zip" size="20" maxlength="40" /></label></p>
- <p><label>Phone Number: <input type="text" name="phone" size="20" maxlength="40" /></label></p>
- <p><label>Email Address: <input type="text" name="email" size="40" maxlength="60" /></label></p>
- </fieldset>
- <p align="center"><input type="submit" name="submit" value="Submit My Information" /></p>
- </form>
- </body>
- </html>
- <PHP START ------------------------------------------------------------------------------------------------------->>
- <?php
- $servername = "localhost";
- $username = "";
- $password = "";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=rlbrown1_computerworld",$username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully </br>";
- $firstname = $_REQUEST['firstname'];
- $lastname = $_REQUEST['lastname'];
- $address = $_REQUEST['address'];
- $city = $_REQUEST['city'];
- $state = $_REQUEST['state'];
- $zip = $_REQUEST['zip'];
- $phone = $_REQUEST['phone'];
- $email = $_REQUEST['email'];
- echo "Thank you for submitting your information ";
- echo $firstname;
- echo $lastname;
- echo ", we have recived the following data from you...";
- echo $firstname;
- echo $lastname;
- echo $address;
- echo $city;
- echo $state;
- echo $zip;
- echo $phone;
- echo $email;
- $sql = "INSERT INTO customers (firstname, lastname, address, city, state, phone, email)";
- VALUES ($firstname, $lastname, $address, $city, $state, $zip, $phone, $email);
- $conn->exec($sql);
- }
- catch (PDOException $e)
- {
- echo "Connection Closed: " . $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement