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"

7 Years
Discussion Span
Last Post by cwarn23

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.

  //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
<title>Form Submission Test</title>
<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">

Sorry I am new to Forms !!! Got PHP files and JS from a friend , but cant configure them properly


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 (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>
Yours Sincerely<br>
        } else {
        $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message'].
    $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";
//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>";

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.