Question: This is a database management homework in which we are dealing with php using xampp and notepad++. Please, I need help and steps explanation. Fix
This is a database management homework in which we are dealing with php using xampp and notepad++. Please, I need help and steps explanation. Fix the following code so it can match the requirements of this homework which are: Create an account with first name (no empty space, print proper validation message), last name ( no empty space, print proper validation message), email, confirm email, password, confirm the password. Password must have 8 characters (alphanumeric). Please, follow this code and the format from the instructor. A photo is attached too.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
// Initialize variables to null. $NameError=""; $EmailError=""; $GenderError=""; $WebsiteError=""; //On Submitting form, below function will execute //Submit Scope starts from here if(isset($_POST['Submit'])){
if(empty($_POST["Name"])){ $NameError="Name is Required"; } else{ $Name=Test_User_Input($_POST["Name"]); // check Name only contains letters and whitespace if(!preg_match("/^[A-Za-z\. ]*$/",$Name)){ $NameError="Only Letters and white sapace are allowed"; } } if(empty($_POST["Email"])){ $EmailError="Email is Required"; } else{ $Email=Test_User_Input($_POST["Email"]); // check if e-mail address syntax is valid or not if(!preg_match("/[a-zA-Z0-9._-]{3,}@[a-zA-Z0-9._-]{3,}[.]{1}[a-zA-Z0-9._-]{2,}/",$Email)) { $EmailError="Invalid Email Format"; } } if(empty($_POST["Gender"])){ $GenderError="Gender is Required"; } else{ $Gender=Test_User_Input($_POST["Gender"]);
} if(empty($_POST["Website"])){ $WebsiteError="Website is Required"; } else{ $Website=Test_User_Input($_POST["Website"]); // check Website address syntax is valid or not
if(!preg_match("/(https:|ftp:)\/\/+[a-zA-Z0-9.\-_\/?\$=&\#\~`!]+\.[a-zA-Z0-9.\-_\/?\$=&\#\~`!]*/",$Website)){ $WebsiteError="Invalid Webside Address Format"; } } if(!empty($_POST["Name"])&&!empty($_POST["Email"])&&!empty($_POST["Gender"])&&!empty($_POST["Website"])){ if((preg_match("/^[A-Za-z\. ]*$/",$Name)==true)&&(preg_match("/[a-zA-Z0-9._-]{3,}@[a-zA-Z0-9._-]{3,}[.]{1}[a-zA-Z0-9._-]{2,}/",$Email)==true)&&(preg_match("/(https:|ftp:)\/\/+[a-zA-Z0-9.\-_\/?\$=&\#\~`!]+\.[a-zA-Z0-9.\-_\/?\$=&\#\~`!]*/",$Website)==true)) { echo " Your Submit Information";echo "Name:".ucwords ($_POST["Name"])." "; echo "Email: {$_POST["Email"]} "; echo "Gender: {$_POST["Gender"]} "; echo "Website: {$_POST["Website"]} "; echo "Comments: {$_POST["Comment"]} "; $emailTo="mail@..."; $subject="Contact Form"; $body=" A person name : ".$_POST["Name"]." With the Email : ".$_POST["Email"]. " have Gender : ". $_POST["Gender"]." have website of: ".$_POST["Website"]. " Added Comment :: ".$_POST["Comment"]; $Sender="From:mail..."; if (mail($emailTo, $subject, $body, $Sender)) { echo "Mail sent successfully!"; } else { echo "Mail not sent!"; } }else{ echo '* Please Complete & Correct your Form & Try Again *'; } } }//Submit Scope Ends here //Function to get and throw data to each of the field final varriable like Name / Gender etc. function Test_User_Input($Data){ return $Data; }
//php code ends here ?>
|
Form Code Project Create an account First name NoT of im Last name Email Confirm Email Password Confirm password I am an instructor By signing in, 1 agree to zyBook's terms of service and Create account Form Code Project Create an account First name NoT of im Last name Email Confirm Email Password Confirm password I am an instructor By signing in, 1 agree to zyBook's terms of service and Create account
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
