+ Reply to Thread
Results 1 to 3 of 3

Thread: e-mail form through php script

  1. #1
    ajnv60 is offline x10Hosting Member ajnv60 is an unknown quantity at this point
    Join Date
    May 2010
    Posts
    1

    e-mail form through php script

    Dear X10Hosting,

    I'm trying to e-mail a form through the following simple "send_form_email.php" script:

    <?php
    $to = "ajnv60@ekijsa.x10hosting.com";
    $subject = "Contact Us";
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;
    $headers = "From: $email";
    $sent = mail($to, $subject, $message, $headers) ;
    if($sent)
    {print "Your mail was sent successfully"; }
    else
    {print "We encountered an error sending your mail"; }
    ?>

    where the form input is collected through

    <form method="post" action="send_form_email.php">
    Name: <input name="name" type="text"><br>
    <br>
    E-mail: <input name="email" type="text"><br>
    <br>
    Message: <textarea name="message" rows="15" cols="40"></textarea> <br>
    <br>
    <input value="Submit" type="submit"> </form>

    Entering form data runs smoothly, but when I hit the submit button the "send_form_email.php" script is shown and the e-mail is not sent.

    Does this functionality work at X10Hosting, and if it does, can you please tell me what I'm doing wrong?

    Thanks!

  2. #2
    Zubair's Avatar
    Zubair is offline x10 Super Spammer Zubair has a reputation beyond reputeZubair has a reputation beyond reputeZubair has a reputation beyond repute
    Join Date
    Jul 2009
    Location
    Pakistan
    Posts
    8,747

    Re: e-mail form through php script

    ***Moved to Programming Help***
    Zubair Barkat | Level 2 Tech
    █ 888-X10-9668 - zubair[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: e-mail form through php script

    What's the URL for the page? You should always include a link to a live page.

    If you're seeing the PHP code in the page source, then PHP isn't processing the page.

    You've got an injection vulnerability via the "email" form input. An attacker can inject arbitrary headers into the message, using it to send spam. Always sanitize user input.
    Last edited by misson; 05-25-2010 at 09:43 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. form mail problem - sends but can't receive mail
    By scotlundy in forum Free Hosting
    Replies: 0
    Last Post: 02-11-2010, 10:04 AM
  2. help with form script please
    By tradervic in forum Programming Help
    Replies: 11
    Last Post: 01-19-2010, 05:13 PM
  3. Best contact form/script to use?
    By xxll_martin_llxx in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 05-03-2009, 11:31 AM
  4. form script help please
    By aphan in forum Programming Help
    Replies: 2
    Last Post: 10-10-2008, 11:22 PM
  5. Passing a form into a cig script
    By smatt454 in forum Free Hosting
    Replies: 3
    Last Post: 09-04-2008, 08:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers