Question:

PHP Questions...Forms...?

by  |  earlier

0 LIKES UnLike

Ok, I have been working on a simple PHP Form script, but it's not working for some reason. Can someone please make a good contact form for my website that actually works. This is the code I had to just test it out to make sure it worked...:

<html>

<head>

<body>

<form name="kevin" method="post" action="index.php">

Enter your email   <input type="text" name="name"><br>

<input type = "button" name="submit" value="Click me to email" >

</form>

</body>

</html>

<?php

if(isset($_POST['submit'])){

$input = $_POST['name'];

print $input;

$subject-"test";

$body="This is a test email";

mail ($name,$subject,$body);

}

?>

Thanks in advanced!!

 Tags:

   Report

5 ANSWERS


  1. i just modify your code...

    copy paste the code...

    if(isset($_POST[&#039;name&#039;])){

    $input = $_POST[&#039;name&#039;];

    $subject=&quot;test&quot;;

    $body=&quot;This is a test email&quot;;

    mail($input,$subject,$body,&quot;From: test@test.com\r\n&quot;);

    }


  2. J2EE Tutorials- http://learnj2ee.info/

  3. change: $subject-&quot;test&quot;;

    to: $subject=&quot;test&quot;;

    note the correction from &quot;-&quot; to &quot;=&quot;

    ---------------------

    Also...I don&#039;t know if this PHP script is in a different document, but it should be because you&#039;re trying to print $input AFTER your &lt;/html&gt; element.

  4. What is this?

  5. &lt;html&gt;

    &lt;head&gt;

    &lt;body&gt;

    &lt;form name=&quot;kevin&quot; method=&quot;post&quot; action=&quot;index.php&quot;&gt;

    Enter your email   &lt;input type=&quot;text&quot; name=&quot;name&quot;&gt;&lt;br&gt;

    &lt;input type = &quot;submit&quot; name=&quot;submit&quot; value=&quot;Click me to email&quot; &gt;

    &lt;/form&gt;

    &lt;/body&gt;

    &lt;/html&gt;

    &lt;?php

    if(isset($_POST[&#039;submit&#039;])){

    $input = $_POST[&#039;name&#039;];

    print $input;

    $subject=&quot;test&quot;;

    $body=&quot;This is a test email&quot;;

    mail ($input,$subject,$body);

    }

    ?&gt;

    Note the changes...  

    1.

    &lt;input type = &quot;button&quot; name=&quot;submit&quot;  changed to

    &lt;input type = &quot;submit&quot; name=&quot;submit&quot;  

    2.   $subject-&quot;test&quot;;   changed to  $subject=&quot;test&quot;;

    3. mail ($name,$subject,$body);   changed to mail ($input,$subject,$body);

    if your smtp configuration is already done, this script will work fine.

    gud luck

Question Stats

Latest activity: earlier.
This question has 5 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.