Skip to main content
nigelh70638339
Inspiring
April 14, 2017
Answered

Contact form on 123.reg

  • April 14, 2017
  • 1 reply
  • 6094 views

Hello,

I need to add a contact for to my site and used a Lynda.com tutorial to set up the initial page.

I have downloaded the script from 123.reg -

<?php

$EmailFrom = "info@yourdomain.co.uk";

$EmailTo = "info@yourdomain.co.uk";

$Subject = "online form";

$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://yourdommain.co.uk/contact.php");

  exit;

}

// prepare email body text

$Body = "";

$Body .= "Name: ";

$Body .= $Name;

$Body .= "\n";

$Body .= "Tel: ";

$Body .= $Tel;

$Body .= "\n";

$Body .= "Email: ";

$Body .= $Email;

$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\">";

}

?>

I know I need to change the "yourdomain" parts but when I upload the php file (this script) I get a 404 message.

I have contacted 123  but was told that they cannot support code queries.

How I  get my contact for to connect to the uploaded php file.

My contact form code is -

<div id="contact">

  <form name="form1" method="post" action="http://www.ultimate-trumps.co.uk/formmail.php">

    <span id="nameTextField">

      <label for="Name"></label>

      <input type="text" name="Name" id="Name">

      <span class="textfieldRequiredMsg">A value is required.</span></span>

    <p><span id="emailTextField">

    <label for="email"></label>

    <input type="text" name="email" id="email">

    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>

    <p><span id="messageTextArea">

    <label for="Your message"></label>

    <textarea name="Your message" id="Your message" cols="45" rows="5"></textarea>

    <span id="countmessageTextArea"> </span><span class="textareaRequiredMsg">A value is required.</span><span class="textareaMinCharsMsg">Minimum number of characters not met.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></p>

    <p>

      <input type="submit" name="submit" id="submit" value="Submit">

    </p>

  </form>

</div>

I have used a SpryAsset to create the code.

Any help is appreciated.

Thanks in advance!

    This topic has been closed for replies.
    Correct answer Nancy OShea

    This script is not where the path says it is.  And that's why you're getting a 404 error.  Check your remote server to ensure the formmail.php script is on your server at root level -- the same as your home page and contact form.

    http://www.ultimate-trumps.co.uk/formmail.php

    Nancy

    1 reply

    Rob Hecker2
    Legend
    April 14, 2017

    A 404 error is not a code error. It means the page can't be found. The file names must be exact as to case.

    Speaking of case. Your use of case is inconsistent, which will lead to tiny problems that you may spend hours trying to resolve. My rule is to NEVER use upper case anywhere it is not necessary. People come to this forum all the time stumped because they can't figure out what's wrong with their code, and the problem turns out to be a simple lack of consistency in the use of case. You capitalize the PHP standard function "trim" but don't capitalize stripslashes. Keep that finger away from the shift key!

    To resolve the 404 error, verify that both files are on the server where they should be and that the file name in the form action exactly matches the actual file name, and that when you call the html form you are using the correct file name.

    nigelh70638339
    Inspiring
    April 14, 2017

    Is there anything from the above that you can see as wrong?

    I have on my server

    formmail.asp (123 added this)

    formmail.php and

    mailtest.php which 123 done to test it. They informed me that they had tested it and all worked OK. Thats as far as the help went.

    Nancy OShea
    Community Expert
    Nancy OSheaCommunity ExpertCorrect answer
    Community Expert
    April 14, 2017

    This script is not where the path says it is.  And that's why you're getting a 404 error.  Check your remote server to ensure the formmail.php script is on your server at root level -- the same as your home page and contact form.

    http://www.ultimate-trumps.co.uk/formmail.php

    Nancy

    Nancy O'Shea— Product User & Community Expert