| | |
Form submission
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2009
Posts: 2
Reputation:
Solved Threads: 0
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"
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"
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.
PHP Syntax (Toggle Plain Text)
<?php if($_POST['submit']=="Submit"&&!empty($_POST['name']&&!empty($_POST['phone'])&&strlen($_POST['phone'])>10&&!empty($_POST['email'])&&# 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'])) { //Form is Valid echo "Thanks! Your submission was sent!"; mail(); //<--Will Not work!! You need a email address, a subject, a body, and headers exit(); //Prevents user from seeing the form again } ?> <html> <head> <title>Form Submission Test</title> </head> <body> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <label for="name">Name: </label><input type="text" name="name" value="<?=$_POST['name']?>"><br/> <label for="phone">Telephone: </label><input type="text" name="phone" value="<?=$_POST['phone']?>"><br/> <label for="email">Email: </label><input type="text" name="email" value="<?=$_POST['email']?>"><br/> <label for="radio">Radio Button</label><input type="radio" name="radio" value="radio1'"><br> <label for="comments">Comments: </label><textarea name="comments"><?=$_POST['name']?></textarea><br> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </form> </body> </html>
Last edited by FlashCreations; Sep 3rd, 2009 at 5:24 am.
If you don't have a basic understanding then perhaps you should check out this article. Also here is some source for basic usage:
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.
php Syntax (Toggle Plain Text)
<? if (isset($_POST['subject']) && $_POST['message']!=='') { $address = "your_real_email@domain.com"; //change this to the receiving address. $subject = "Website Email: ".$_POST['subject']; if ($_POST['name']!=='') { $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message']."<br> <br> Yours Sincerely<br> ".$_POST['name']."</td></tr></table>"; } else { $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message']. "</td></tr></table>"; } $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: do_not_reply@your_website_form' . "\r\n"; mail($address,$subject,$body,$headers); } //below displays the form while above processes it. echo "<form method='post'>Subject: <input type=text value='' maxlength=100 name='subject' size=30><br> <textarea cols=30 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name'> <input type='submit' value='submit'></form>"; ?>
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
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
![]() |
Similar Threads
- Prevent Form Submission (JSP)
- preview option before form submission (PHP)
- Automated form submission (Python)
- Help with asp form will not display contact information (ASP)
- Problems in Dynaform (Form Mail) URGENT HELP (PHP)
- multiple recipients on FP form submission (HTML and CSS)
- Changing the page after a form (HTML and CSS)
Other Threads in the PHP Forum
- Previous Thread: Invalid argument supplied for foreach()
- Next Thread: how to seprate php with html
| Thread Tools | Search this Thread |
301 ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dynamic echo email error execution file files folder foreach form forms function functions google href htaccess html httppost image include insert integration ip java javascript joomla library limit link links login loop mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem query radio random recursion regex remote script search searchbox server session sessions sms soap sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website xml youtube zend






