Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Registration Page
- <html>
- <body>
- <h3>Registration Form</h3><br>
- <form action="thankyou.php" method="post">
- First name: <input type="text" name="fname"><br>
- Last name: <input type="text" name="lname"><br>
- Age: <input type="number" name="age"><br>
- Address: <input type="text" name="address"><br>
- E-Mail Address: <input type="text" name="email"><br>
- Would you like to receive e-mails with discounts and special offers?:
- <input type="checkbox" name="optin"><br>
- Enter Image Text
- <input name="captcha" type="text">
- <img src="captcha.php" /><br>
- <input type="submit" value="Submit">
- </form>
- </body>
- </html>
- //ThankYou Page
- $servername = "localhost";
- $username = "";
- $password = "";
- $dbname = "";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- else {
- $newaddress = $_POST["address"];
- $newage = $_POST["age"];
- $newemail = $_POST["email"];
- $newfname = $_POST["fname"];
- $newlname = $_POST["lname"];
- $newoptin = $_POST["optin"];
- if ($newoptin == "on")
- {
- $newoptin = 1;
- }
- else {
- $newoptin = 0;
- }
- $sql = "INSERT INTO UserInfo (Address, Age, Email, FirstName, LastName, Offers)
- VALUES ('$newaddress', '$newage', '$newemail', '$newfname', '$newlname', $newoptin)";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- }
- else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- echo '<h4>Thank you!</h4>';
- echo '<h2>A representative will contact you within 5 business days if</h2>';
- echo '<h2>you meet the requirements to begin the free trial.</h2>';
- }
- }
- else
- {
- die("Wrong Code Entered - Please go back using browser back button and try again.");
- }
- ?>
- </body>
- </html>
- //CAPTCHA
- <?php
- session_start();
- $code=rand(1000,9999);
- $_SESSION["code"]=$code;
- $im = imagecreatetruecolor(50, 24);
- $bg = imagecolorallocate($im, 22, 86, 165); //background color blue
- $fg = imagecolorallocate($im, 255, 255, 255);//text color white
- imagefill($im, 0, 0, $bg);
- imagestring($im, 5, 5, 5, $code, $fg);
- header("Cache-Control: no-cache, must-revalidate");
- header('Content-type: image/png');
- imagepng($im);
- imagedestroy($im);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement