Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    making a website and wanting to put up a contact table. I've created the table already on dreamweaver and tried creating a php but every time i click the submit button just pastes the script code on the website could anyone help me in what i might be doing wrong please.

    this is the script that i am using:

    <?php



    $EmailFrom = "";

    $EmailTo = "[email protected]";

    $Subject = "new message from website";

    $Name = Trim(stripslashes($_POST['Name']));

    $Email = Trim(stripslashes($_POST['Email']));

    $Tel = Trim(stripslashes($_POST['Tel']));

    $Message = Trim(stripslashes($_POST['Message']));

    // validation

    $validationOK=true;

    if (!$validationOK) {

    echo "please check your details";

    header("Location: http:///contactform.php");

    exit;

    }



    // prepare email body text



    $Body = "";

    $Body .= "Name: ";

    $Body .= $Name;

    $Body .= "\n";

    $Body .= "Email: ";

    $Body .= $Email;

    $Body .= "\n";

    $Body .= "Telephone Number (optional): ";

    $Body .= $Telephone Number (optional);

    $Body .= "\n";

    $Body .= "Message: ";

    $Body .= $Message;

    $Body .= "\n";



    // send email

    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");



    // redirect to success page

    if ($success){

    print "<meta http-equiv=\"refresh\" content=\"1;URL=index.php\">";

    }

    else{

    print "<meta http-equiv=\"refresh\" content=\"1;URL=index.php\">";

    }

    ?>
    Offline

    2
    ReputationRep:
    Does the server you're running this on have PHP installed?
    Offline

    0
    ReputationRep:
    (Original post by tiana)
    making a website and wanting to put up a contact table. I've created the table already on dreamweaver and tried creating a php but every time i click the submit button just pastes the script code on the website could anyone help me in what i might be doing wrong please.

    this is the script that i am using:

    &lt;?php



    $EmailFrom = &quot;&quot;;

    $EmailTo = &quot;[email protected]&quot; ;

    $Subject = &quot;new message from website&quot;;

    $Name = Trim(stripslashes($_POST['Name']));

    $Email = Trim(stripslashes($_POST['Email']));

    $Tel = Trim(stripslashes($_POST['Tel']));

    $Message = Trim(stripslashes($_POST['Message']));

    // validation

    $validationOK=true;

    if (!$validationOK) {

    echo &quot;please check your details&quot;;

    header(&quot;Location: http:///contactform.php&quot;

    exit;

    }



    // prepare email body text



    $Body = &quot;&quot;;

    $Body .= &quot;Name: &quot;;

    $Body .= $Name;

    $Body .= &quot;\n&quot;;

    $Body .= &quot;Email: &quot;;

    $Body .= $Email;

    $Body .= &quot;\n&quot;;

    $Body .= &quot;Telephone Number (optional): &quot;;

    $Body .= $Telephone Number (optional);

    $Body .= &quot;\n&quot;;

    $Body .= &quot;Message: &quot;;

    $Body .= $Message;

    $Body .= &quot;\n&quot;;



    // send email

    $success = mail($EmailTo, $Subject, $Body, &quot;From: &lt;$EmailFrom&gt;&quot;



    // redirect to success page

    if ($success){

    print &quot;&lt;meta http-equiv=\&quot;refresh\&quot; content=\&quot;1;URL=index.php\& quot;&gt;&quot;;

    }

    else{

    print &quot;&lt;meta http-equiv=\&quot;refresh\&quot; content=\&quot;1;URL=index.php\& quot;&gt;&quot;;

    }

    ?&gt;
    http://www.jabrannawaz.me/tutorials/...orial.php?id=8
    Offline

    15
    ReputationRep:
    If you are trying to run this on your computer, you need php and a few other things installed. Have a look at either wamp or xampp, they will let you do it. Else, you will need to get some form of hosting to use.
 
 
 
Poll
Black Friday: Yay or Nay?
Useful resources

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.