Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2

    Problem with form... yet again php defeats me


    hey im using this for a webform

    <?php

    $name = $HTTP_POST['name'];
    $email = $HTTP_POST['email'];
    $subject = $HTTP_POST['subject'];
    $message = $HTTP_POST['message'];
    $subscribe = $HTTP_POST['subscribe'];
    $agree = $HTTP_POST['agree'];

    $to = "no1spot@outlook.com";
    $subject = "Conctact message from Draig Racing website: " . $subject;
    $body = $email . " has submited the contact form from Draig Racing website with following content:\n\n
    name: " . $name."\n\r
    email: " . $email."\n\r
    subject: " . $subject."\n\r
    subscribe: " . $subscribe."\n\r
    agree: " . $agree."\n\r";

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

    header("Location: http://draigracing.co.uk/Draigracingnewsite/contact.html");

    ?>

    i tested the form out but im only getting the fields, and the content that i filled in the fields is empty....

    any help would be great.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Posts
    31
    Rep Power
    7
    PHP Code:
    <?php

    $name 
    $_POST['name'];
    $email $_POST['email'];
    $subject $_POST['subject'];
    $message $_POST['message'];
    $subscribe $_POST['subscribe'];
    $agree $_POST['agree'];

    $to "no1spot@outlook.com";

    $subject "Conctact message from Draig Racing website: ".$subject;

    $body $email." has submited the contact form from Draig 

    Racing website with following content:\n\n
        name: "
    .$name."\n\r
        email: "
    .$email."\n\r
        subject: "
    .$subject."\n\r
        subscribe: "
    .$subscribe."\n\r
        agree: "
    .$agree."\n\r";

    mail($to$subject$body);

    header("Location: http://draigracing.co.uk/Draigracingnewsite/contact.html");

    ?>
    Should work... have you tried echoing your post variables to make sure they're actually passing from the form? Always the first step...

    Also, consider using security in your post variables. Just sayin
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2
    Originally Posted by Jax2
    PHP Code:
    <?php

    $name 
    $_POST['name'];
    $email $_POST['email'];
    $subject $_POST['subject'];
    $message $_POST['message'];
    $subscribe $_POST['subscribe'];
    $agree $_POST['agree'];

    $to "no1spot@outlook.com";

    $subject "Conctact message from Draig Racing website: ".$subject;

    $body $email." has submited the contact form from Draig 

    Racing website with following content:\n\n
        name: "
    .$name."\n\r
        email: "
    .$email."\n\r
        subject: "
    .$subject."\n\r
        subscribe: "
    .$subscribe."\n\r
        agree: "
    .$agree."\n\r";

    mail($to$subject$body);

    header("Location: http://draigracing.co.uk/Draigracingnewsite/contact.html");

    ?>
    Should work... have you tried echoing your post variables to make sure they're actually passing from the form? Always the first step...

    Also, consider using security in your post variables. Just sayin
    hi jax,

    thanks for your reply, now this may sound dumb but.....

    Echoing...... what do you mean?

    also security you on about captcha or something like that?

    regards
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,868
    Rep Power
    368
    he means do echo $_POST['variable']; to see what value it is.

    for security he means, check if the data user enters is valid, having said that, unless i a mmistaken, you are just sending an email so security implications are minimal compared to if you are using data elsewhere (i.e storing it into db and tehn outputting it elsewherE)
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2
    ok like im dumb and new to this php.

    where would i stick the echo?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    667
    Rep Power
    6
    As long as the item being echoed does have to be set first, you can post it at the very begining, like before you set 'name','email','subject',...

    Do something similar to:

    PHP Code:
    echo "Name: " $_POST['name'] . "<br />\n";
    echo 
    "E-mail: " $_POST['email'] . "<br />\n";
    echo 
    "Subject: " $_POST['subject'] . "<br />\n";
    ..... 
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2
    ok, so i add this is there a particular place i should add it?

    then what does it do does it creat a file for me to view?

    do i need to fill the form in and email it to me to see the outcome?

    like i said i am really new to this so all help in this is greatly appreciated
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    667
    Rep Power
    6
    Yes. Add them before your $name = $_POST['name']; line.

    You will need to fill out and submit the form. Also comment out your header() for now so you don't get redirected and get a chance to read these outputs.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2
    Originally Posted by Triple_Nothing
    Yes. Add them before your $name = $_POST['name']; line.

    You will need to fill out and submit the form. Also comment out your header() for now so you don't get redirected and get a chance to read these outputs.
    ok so just take out the http link in the header and leave it blank correct
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2
    Originally Posted by w3l54666
    ok so just take out the http link in the header and leave it blank correct
    <?php

    echo $name = $HTTP_POST['name'];
    echo $email = $HTTP_POST['email'];
    echo $subject = $HTTP_POST['subject'];
    echo $message = $HTTP_POST['message'];
    echo $subscribe = $HTTP_POST['subscribe'];
    echo $agree = $HTTP_POST['agree'];

    $to = "no1spot@outlook.com";
    $subject = "Conctact message from Draig Racing website: " . $subject;
    $body = $email . " has submited the contact form from Draig Racing website with following content:\n\n
    name: " . $name."\n\r
    email: " . $email."\n\r
    subject: " . $subject."\n\r
    subscribe: " . $subscribe."\n\r
    agree: " . $agree."\n\r";

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

    header();

    ?>

    is this correct???
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2
    ok so this is what i come up with

    <?php

    echo $name = $HTTP_POST['name']. "<br />\n";
    echo $email = $HTTP_POST['email']. "<br />\n";
    echo $subject = $HTTP_POST['subject']. "<br />\n";
    echo $message = $HTTP_POST['message']. "<br />\n";
    echo $subscribe = $HTTP_POST['subscribe']. "<br />\n";
    echo $agree = $HTTP_POST['agree']. "<br />\n";

    $to = "no1spot@outlook.com";
    $subject = "Conctact message from Draig Racing website: " . $subject;
    $body = $email . " has submited the contact form from Draig Racing website with following content:\n\n
    name: " . $name."\n\r
    email: " . $email."\n\r
    subject: " . $subject."\n\r
    subscribe: " . $subscribe."\n\r
    agree: " . $agree."\n\r";

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

    header(0);

    but the page comes back blank....??????

    now im confused
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    667
    Rep Power
    6
    In PHP, // will comment out a line. So you need to comment out your header, otherwise it will run, and we don't want this right now.


    PHP Code:
    echo "Name: " $_POST['name'] . "<br />\n"
    echo 
    "E-mail: " $_POST['email'] . "<br />\n"
    echo 
    "Subject: " $_POST['subject'] . "<br />\n";
    //echo $message = $HTTP_POST['message']. "<br />\n";
    //echo $subscribe = $HTTP_POST['subscribe']. "<br />\n";
    //echo $agree = $HTTP_POST['agree']. "<br />\n";


    $name $HTTP_POST['name'];
    $email $HTTP_POST['email'];
    $subject $HTTP_POST['subject'];
    $message $HTTP_POST['message'];
    $subscribe $HTTP_POST['subscribe'];
    $agree $HTTP_POST['agree'];

    $to "no1spot@outlook.com";
    $subject "Conctact message from Draig Racing website: " $subject;
    $body $email " has submited the contact form from Draig Racing website with following content:\n\n
    name: " 
    $name."\n\r
    email: " 
    $email."\n\r
    subject: " 
    $subject."\n\r
    subscribe: " 
    $subscribe."\n\r
    agree: " 
    $agree."\n\r";
     
    mail($to$subject$body);
     
    //header("Location: http://draigracing.co.uk/Draigracingnewsite/contact.html"); 
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2
    Originally Posted by Triple_Nothing
    In PHP, // will comment out a line. So you need to comment out your header, otherwise it will run, and we don't want this right now.


    PHP Code:
    echo "Name: " $_POST['name'] . "<br />\n"
    echo 
    "E-mail: " $_POST['email'] . "<br />\n"
    echo 
    "Subject: " $_POST['subject'] . "<br />\n";
    //echo $message = $HTTP_POST['message']. "<br />\n";
    //echo $subscribe = $HTTP_POST['subscribe']. "<br />\n";
    //echo $agree = $HTTP_POST['agree']. "<br />\n";


    $name $HTTP_POST['name'];
    $email $HTTP_POST['email'];
    $subject $HTTP_POST['subject'];
    $message $HTTP_POST['message'];
    $subscribe $HTTP_POST['subscribe'];
    $agree $HTTP_POST['agree'];

    $to "no1spot@outlook.com";
    $subject "Conctact message from Draig Racing website: " $subject;
    $body $email " has submited the contact form from Draig Racing website with following content:\n\n
    name: " 
    $name."\n\r
    email: " 
    $email."\n\r
    subject: " 
    $subject."\n\r
    subscribe: " 
    $subscribe."\n\r
    agree: " 
    $agree."\n\r";
     
    mail($to$subject$body);
     
    //header("Location: http://draigracing.co.uk/Draigracingnewsite/contact.html"); 
    ok tripple should i just coppy this php script now?

    i used the form and what i got in the email was <br /> on all lines
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    667
    Rep Power
    6
    After u submit your form, View Source, and paste the whole code provided to you here, surrounded w/ [C0DE][/C0DE] tags.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    52
    Rep Power
    2
    Originally Posted by Triple_Nothing
    After u submit your form, View Source, and paste the whole code provided to you here, surrounded w/ [C0DE][/C0DE] tags.
    Code:
     
    
    
    echo "Name: " . $_POST['name'] . "<br />\n";  
    echo "E-mail: " . $_POST['email'] . "<br />\n";  
    echo "Subject: " . $_POST['subject'] . "<br />\n"; 
    //echo $message = $HTTP_POST['message']. "<br />\n"; 
    //echo $subscribe = $HTTP_POST['subscribe']. "<br />\n"; 
    //echo $agree = $HTTP_POST['agree']. "<br />\n"; 
    
    
    $name = $HTTP_POST['name']; 
    $email = $HTTP_POST['email']; 
    $subject = $HTTP_POST['subject']; 
    $message = $HTTP_POST['message']; 
    $subscribe = $HTTP_POST['subscribe']; 
    $agree = $HTTP_POST['agree']; 
    
    $to = "no1spot@outlook.com"; 
    $subject = "Conctact message from Draig Racing website: " . $subject; 
    $body = $email . " has submited the contact form from Draig Racing website with following content:\n\n 
    name: " . $name."\n\r 
    email: " . $email."\n\r 
    subject: " . $subject."\n\r 
    subscribe: " . $subscribe."\n\r 
    agree: " . $agree."\n\r"; 
      
    mail($to, $subject, $body); 
      
    //header("Location: http://draigracing.co.uk/Draigracingnewsite/contact.html");
    
    ?>
    <!-- Hosting24 Analytics Code -->
    <script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
    <!-- End Of Analytics Code -->
    and this is what came back exactly after i pressed submit

    echo "Name: " . $_POST['name'] . "
    \n"; echo "E-mail: " . $_POST['email'] . "
    \n"; echo "Subject: " . $_POST['subject'] . "
    \n"; //echo $message = $HTTP_POST['message']. "
    \n"; //echo $subscribe = $HTTP_POST['subscribe']. "
    \n"; //echo $agree = $HTTP_POST['agree']. "
    \n"; $name = $HTTP_POST['name']; $email = $HTTP_POST['email']; $subject = $HTTP_POST['subject']; $message = $HTTP_POST['message']; $subscribe = $HTTP_POST['subscribe']; $agree = $HTTP_POST['agree']; $to = "no1spot@outlook.com"; $subject = "Conctact message from Draig Racing website: " . $subject; $body = $email . " has submited the contact form from Draig Racing website with following content:\n\n name: " . $name."\n\r email: " . $email."\n\r subject: " . $subject."\n\r subscribe: " . $subscribe."\n\r agree: " . $agree."\n\r"; mail($to, $subject, $body); //header("Location: http://draigracing.co.uk/Draigracingnewsite/contact.html"); ?>
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo