Jump to content

msauer

Members
  • Posts

    7
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

msauer's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. The form is part of the code posted above - everything is in 1 file. Thanks
  2. Awesome - Thank you so Much! I know say if not submit - show form otherwise send email and redirect so the form is coming up but it submits with no data if I click submit. It is overlooking my entire validation section on top.
  3. Thanks - I will go and disable them - Oh thank you for suggesting that tool - I put the code throught the checker and found a couple of syntax errors so now the page doesn't load blank. At the moment when I load the page - it goes straight to the page I am redirecting it to. The form is not coming up. I am receiviing an email from the submission Here is the updated code:<?php$name = $email = $gender = $comment = $website = "";$nameErr = $emailErr = $genderErr = $commentErr = $websiteErr = "";if ($_SERVER["REQUEST_METHOD"] == "POST"){if (empty($_POST["name"])){$nameErr = "Name is required";}else{$name = test_input($_POST["name"]);// check if name only contains letters and whitespaceif (!preg_match("/^[a-zA-Z ]*$/",$name)){$nameErr = "Only letters and white space allowed";}}if (empty($_POST["email"])){$emailErr = "Email is required";}else{$email = test_input($_POST["email"]);// check if e-mail address syntax is validif (!preg_match("/([w-]+@[w-]+.[w-]+)/",$email)){$emailErr = "Invalid email format";}}if (empty($_POST["website"])){$website = "";}else{$website = test_input($_POST["website"]);// check if URL address syntax is valid (this regular expression also allows dashes in the URL)if (!preg_match("/b(? ?:https?|ftp)://|www.)[-a-z0-9+&@#/%?=~_|!:,.;]*[-a-z0-9+&@#/%=~_|]/i",$website)){$websiteErr = "Invalid URL";}}if (empty($_POST["comment"])){$comment = "";}else{$comment = test_input($_POST["comment"]);}if (empty($_POST["gender"])){$genderErr = "Gender is required";}else{$gender = test_input($_POST["gender"]);}}function test_input($data){$data = trim($data);$data = stripslashes($data);$data = htmlspecialchars($data);return $data;}<?phpif(isset($_POST["submit"])){?><form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">Name: <input type="text" name="name" value="<?php echo $name;?>"><span class="error">* <?php echo $nameErr;?></span><br><br />E-mail: <input type="text" name="email" value="<?php echo $email;?>"><span class="error">* <?php echo $emailErr;?></span><br><br />Website: <input type="text" name="website" value="<?php echo $website;?>"><span class="error"><?php echo $websiteErr;?></span><br><br />Gender:<input type="radio" name="gender"<?php if (isset($gender) && $gender=="female") echo "checked";?>value="female">Female<input type="radio" name="gender"<?php if (isset($gender) && $gender=="male") echo "checked";?>value="male">Male<span class="error">* <?php echo $genderErr;?></span><br><br />Comment:<br /><textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea><br><br /><input type="submit" name="submit" value="Submit"></form><!--end of form area--><?php}else{$from = 'From: domain Loyalty Web Page Form <offers@domain.com>';$to = 'Offers@domain.com';$subject = 'Sign Me Up ';$body = "Comments were sent via the Loyalty Offer Websiten";$body."<strong>Name:</strong> " . $name . "<br>" ."<strong>Email:</strong> " . $email . "<br>" ."<strong>Website:</strong> " . $website . "<br><br>" ."<strong>Gender:</strong> " . $gender . "<br><br>";mail($to,$subject,$body,$from);mail($email, "Thank you for Signing Up", "Dear $name,n Thank you for Signing Up for the Loyalty program. n I am sure you will enjoy the benefits we have to offer. n Thank You,nDomain ",$from);header('Location: http://www.domain.com/typage.php');}?>
  4. The line with the icon is getting converted when I post it
  5. Interesting - where did that worried icon face come from? hmmm
  6. Hi Thank You for your response. I am in the process of setting up WAMP - Once I figure out why localhost doesn't want to run my page - I will get into the "ini' file but in the meanwhile I am uploading to a webserver and working that way. I don't have access to the "ini" file With regards to the code - here is what I put together during the tutorial - any advice is greatly appreciated – Thanks in Advance!<?php$name = $email = $gender = $comment = $website = "";$nameErr = $emailErr = $genderErr = $commentErr = $websiteErr = "";if ($_SERVER["REQUEST_METHOD"] == "POST"){if (empty($_POST["name"])){$nameErr = "Name is required";}else{$name = test_input($_POST["name"]);// check if name only contains letters and whitespaceif (!preg_match("/^[a-zA-Z ]*$/",$name)){$nameErr = "Only letters and white space allowed";}}if (empty($_POST["email"])){$emailErr = "Email is required";}else{$email = test_input($_POST["email"]);// check if e-mail address syntax is validif (!preg_match("/([w-]+@[w-]+.[w-]+)/",$email)){$emailErr = "Invalid email format";}}if (empty($_POST["website"])){$website = "";}else{$website = test_input($_POST["website"]);// check if URL address syntax is valid (this regular expression also allows dashes in the URL)if (!preg_match("/b(? ?:https?|ftp)://|www.)[-a-z0-9+&@#/%?=~_|!:,.;]*[-a-z0-9+&@#/%=~_|]/i",$website)){$websiteErr = "Invalid URL";}}if (empty($_POST["comment"])){$comment = "";}else{$comment = test_input($_POST["comment"]);}if (empty($_POST["gender"])){$genderErr = "Gender is required";}else{$gender = test_input($_POST["gender"]);}}function test_input($data){$data = trim($data);$data = stripslashes($data);$data = htmlspecialchars($data);return $data;}?><!--start main content area--><?phpif(isset($_POST["submit"])){?><form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">Name: <input type="text" name="name" value="<?php echo $name;?>"><span class="error">* <?php echo $nameErr;?></span><br><br />E-mail: <input type="text" name="email" value="<?php echo $email;?>"><span class="error">* <?php echo $emailErr;?></span><br><br />Website: <input type="text" name="website" value="<?php echo $website;?>"><span class="error"><?php echo $websiteErr;?></span><br><br />Gender:<input type="radio" name="gender"<?php if (isset($gender) && $gender=="female") echo "checked";?>value="female">Female<input type="radio" name="gender"<?php if (isset($gender) && $gender=="male") echo "checked";?>value="male">Male<span class="error">* <?php echo $genderErr;?></span><br><br />Comment:<br /><textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea><br><br /><input type="submit" name="submit" value="Submit"></form><!--end of form area--><?php}else{$from = 'From: Loyalty Web Page Form <offers@domain.com>';$to = 'Offers@domain.com';$subject = 'Sign Me Up For Loyalty Offer ';$site = 'http://www.domain.com';$body = "Comments were sent via the Loyalty Offer on the domain Websiten";$body . ="<strong>Name:</strong> " . $name . "<br>" ."<strong>Email:</strong> " . $email . "<br>" ."<strong>Website:</strong> " . $website . "<br><br>" ."<strong>Gender:</strong> " . $gender . "<br><br>";mail($to,$subject,$body,$from);mail($email, "Thank you for Signing Up", "Dear $name,n Thank you for Signing Up. n I am sure you will enjoy the benefits domain has to offer. n Thank You,nDomain",$from);header('Location: http://www.domain.com/typage.php');}}?>
  7. Hi, I am new to the W3School Forums. This past week I worked through the W3School “PHP Forms” section of the tutorial and all went well. I created a form, did the checks, then the validations and displayed the collected data on the screen. Now I want to email the data instead of displaying it and I am now working though the W3School “The PHP mail() Function” section of the tutorial, I have successfully sent the email without doing all the checks and validation, but when I attempted to merge it with the email fuctions start to go wrong - I get a blank screen. Not sure what I am doing incorrectly. I am already bald on one spot from pulling my hair. I have made so many adjustments that I now have confused myself. Can someone please offer a keen eye and some advice – pleeeeeeease What is the best way to post code so it doesn't post like a big lump of text and symbols. Any advice is greatly appreciated – Thanks in Advance! I tried uploading the code in a word document but got message that I don't have permission to upload this kind of file. What kind of files are accepted? Thanks a Bunch! M
×
×
  • Create New...