Form submission

Reply

Join Date: Sep 2009
Posts: 2
Reputation: pradeeprs is an unknown quantity at this point 
Solved Threads: 0
pradeeprs pradeeprs is offline Offline
Newbie Poster

Form submission

 
0
  #1
Sep 3rd, 2009
Can some one help me to create a form & send the results to my e mail address?? and cc as well to another one ?
Field Names : Name , Telephone No (should get validated to c the user enters more than 10 numbers) , E Mail address (should get validated to c whether the user has entered a correct e mail format) , Radio button, and commens area please.Submit & reset buttons.We need to make sure that certain feilds such as name , comments cant keep "blank"
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 849
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 138
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark

Re: Form submission

 
0
  #2
Sep 3rd, 2009
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 184
Reputation: FlashCreations is an unknown quantity at this point 
Solved Threads: 15
FlashCreations's Avatar
FlashCreations FlashCreations is offline Offline
Junior Poster

Re: Form submission

 
0
  #3
Sep 3rd, 2009
Since you didn't give your email address, nor did you specify the address to CC to I've just put a empty mail function there. If you can provide a email addresses I can help you out. For more on mail() see the PHP.net documentation.
  1. <?php
  2. if($_POST['submit']=="Submit"&&!empty($_POST['name']&&!empty($_POST['phone'])&&strlen($_POST['phone'])>10&&!empty($_POST['email'])&&#
  3. preg_match('/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/',$_POST['email'])&&!empty($_POST['comments']))
  4. {
  5. //Form is Valid
  6. echo "Thanks! Your submission was sent!";
  7. mail(); //<--Will Not work!! You need a email address, a subject, a body, and headers
  8. exit(); //Prevents user from seeing the form again
  9. }
  10. ?>
  11. <html>
  12. <head>
  13. <title>Form Submission Test</title>
  14. </head>
  15. <body>
  16. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  17. <label for="name">Name: </label><input type="text" name="name" value="<?=$_POST['name']?>"><br/>
  18. <label for="phone">Telephone: </label><input type="text" name="phone" value="<?=$_POST['phone']?>"><br/>
  19. <label for="email">Email: </label><input type="text" name="email" value="<?=$_POST['email']?>"><br/>
  20. <label for="radio">Radio Button</label><input type="radio" name="radio" value="radio1'"><br>
  21. <label for="comments">Comments: </label><textarea name="comments"><?=$_POST['name']?></textarea><br>
  22. <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset">
  23. </form>
  24. </body>
  25. </html>
Last edited by FlashCreations; Sep 3rd, 2009 at 5:24 am.
FlashCreations
(aka PhpMyCoder)

About Me | My Blog | Contact Me
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 2
Reputation: pradeeprs is an unknown quantity at this point 
Solved Threads: 0
pradeeprs pradeeprs is offline Offline
Newbie Poster

Re: Form submission

 
0
  #4
Sep 3rd, 2009
Sorry I am new to Forms !!! Got PHP files and JS from a friend , but cant configure them properly
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,478
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Form submission

 
0
  #5
Sep 3rd, 2009
If you don't have a basic understanding then perhaps you should check out this article. Also here is some source for basic usage:
  1. <?
  2. if (isset($_POST['subject']) && $_POST['message']!=='')
  3. {
  4. $address = "your_real_email@domain.com"; //change this to the receiving address.
  5. $subject = "Website Email: ".$_POST['subject'];
  6. if ($_POST['name']!=='')
  7. {
  8. $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message']."<br>
  9. <br>
  10. Yours Sincerely<br>
  11. ".$_POST['name']."</td></tr></table>";
  12. } else {
  13. $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message'].
  14. "</td></tr></table>";
  15. }
  16. $headers = 'MIME-Version: 1.0' . "\r\n";
  17. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  18. $headers .= 'From: do_not_reply@your_website_form' . "\r\n";
  19.  
  20. mail($address,$subject,$body,$headers);
  21. }
  22. //below displays the form while above processes it.
  23. echo "<form method='post'>Subject: <input type=text value='' maxlength=100 name='subject' size=30><br>
  24. <textarea cols=30 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name'>
  25. <input type='submit' value='submit'></form>";
  26. ?>
If you don't have a clue what any of that code means then you have some studying to do. That code only uses basic concepts which you would use in every day coding. So perhaps a few php tutorials might help.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC