My Assistant
![]() ![]() |
|
|
Feb 18 2012, 09:37 PM
Post
#1
|
|
|
UtterAccess Guru Posts: 774 From: South Carolina, USA |
I am struggling with creating a form that will allow people to send their mailing address for a free offer. Have found/tested many methods to do this, and my form is very simple, only asking their name, email, and mailing address, and then it has a 'submit' button to email the request so the order can be processed. Am very new to this and am bumping into problems. First, I have found many many websites that offer easy, free drag 'n' drop design, they are nice, using/testing several I learned some helpful things, but did not like that my form was tied to their websites, I could not find a way to get to the 'submit' button and edit the email, etc. Not at all like Access where it's easy to get to the code behind a button and work with it.
Found a sample go-by here that was the most understandable for my level of knowledge in this, and removed fields I didn't need till I got the html form the way I wanted it, and most of the output.php file worked out, but am struggling with the validation part. Because I renamed a field and deleted others, and don't know anything about php except where I'm told to edit things when needed (shopping cart had alot of that . . . ), if I leave below code in the php file and test the form, it thinks my form has incomplete data and the error.html popls up (because I deleted some fields, I think), and if I take it out, the submit button works fine, the test email comes ok to me. However, I do want to get the validation back in there and don't know how. Have been researching php validation and so far it's just not making sense to me. Also I'm reading that the ereg mentioned in code is being depreciated. Any ideas on how to modify for the changes I've made to the form fields, matching the php names to the html form revisions? Thank you! CODE // Validation if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email)) { header("Location: error.html"); exit; } The full php file reads: CODE <?php
// Receiving variables @$full_name = addslashes($_POST['full_name']); @$email = addslashes($_POST['email']); @$address = addslashes($_POST['address']); // Validation if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email)) { header("Location: error.html"); exit; } //Sending Email to form owner # Email to Owner $pfw_header = "From: $email"; $pfw_subject = "Free Book Offer"; $pfw_email_to = "myemail@email.com"; $pfw_message = "full_name: $full_name\n" . "email: $email\n" . "address: $address\n" . "full_name: $full_name\n" . "email: $email\n" . "address: $address\n" . "\n" . "Thank you for requesting:\n" . "This offer\n" . "http://www.mydomain.com\n" . "\n"; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ); header("Location: thank-you.html"); ?> This post has been edited by SparrowCathy: Feb 18 2012, 09:39 PM |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 09:29 AM |