-1

i can see that the variables that contains $_POST("something"); are always empty... that's my code:

<form action="php/mail_send.php">
           <input autocomplete="off" onfocus="if (this.value=='Name') this.value = ''" onblur="if (this.value=='') this.value = 'Name'" style="border: solid 1px; border-radius: 5px; height:25px; border-color: white; width: 65%; "  value="Name" type="text" name="name">
           <input autocomplete="off" onfocus="if (this.value=='E-Mail') this.value = ''" onblur="if (this.value=='') this.value = 'E-Mail'" style="margin-top: 20px; border: thin 1px; border-radius: 5px;  height:25px; border-color: white; width: 65%" value="E-Mail" type="email" name="email">
           <input autocomplete="off" onfocus="if (this.value=='Subject') this.value = ''" onblur="if (this.value=='') this.value = 'Subject'" style="margin-top: 20px; border: thin 1px; border-radius: 5px; height:25px;  border-color: white; width: 65%" value="Subject" type="text" name="subject">
           <textarea class="txt_field" style="    color: #99a0aa;margin-top: 20px;  font: normal normal 16px/20px pnova-regular, helvetica, sans-serif; border: thin 1px; border-radius: 5px; border-color: white; width: 65%; height: 300px;" type="text" name="message">Message</textarea>
           <input style="margin-top: 20px; border: thin 1px; border-radius: 10px; border-color: white; cursor:pointer; background-color: #4db849; width:65%; height: 45px; color: white; font-weight: 700;" type="submit" value="Send Message">
       </form>

and thats php code for e-mail send:

<?php 
$name = $_POST['name']; 
$message = $_POST['message'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $message.$email.$name;
mail("thomasrossimel@outlook.it", $subject, $message);
echo "<script language='javascript'>
alert('Mail sent successfully');
</script>";
echo("<script>location.href = 'http://rossimelthomas.com';</script>");
?>

any ideas?? it doesn't work :(

  • 4
    `autocomplete="off"` - WHY? Are you trying to piss off your users? Chances are good that they have their name/email already available as autocompletion for those fields. – ThiefMaster Dec 25 '14 at 14:57
  • 1
    Also, instead of this onfocus/onblur mess you can simply use `placeholder="Name"` etc. and let the browser deal with showing/hiding that text. – ThiefMaster Dec 25 '14 at 14:58
  • 1
    And you have `error_reporting` disabled. Just E_ALL that and your form issue becomes obvious. – mario Dec 25 '14 at 14:58
  • 1
    You're making a GET request, but reading `$_POST`. – Musa Dec 25 '14 at 14:59

1 Answers1

0

Because you haven't specified any method in the form hence it will be using GET method by default

you need to explicitly specify that you want to use post method

here is the modified code

it works like charm

        <form action="mail.php" method="POST">
        <input autocomplete="off" onfocus="if (this.value=='Name') this.value = ''" onblur="if (this.value=='') this.value = 'Name'" style="border: solid 1px; border-radius: 5px; height:25px; border-color: white; width: 65%; "  value="Name" type="text" name="name">
        <input autocomplete="off" onfocus="if (this.value=='E-Mail') this.value = ''" onblur="if (this.value=='') this.value = 'E-Mail'" style="margin-top: 20px; border: thin 1px; border-radius: 5px;  height:25px; border-color: white; width: 65%" value="E-Mail" type="email" name="email">
        <input autocomplete="off" onfocus="if (this.value=='Subject') this.value = ''" onblur="if (this.value=='') this.value = 'Subject'" style="margin-top: 20px; border: thin 1px; border-radius: 5px; height:25px;  border-color: white; width: 65%" value="Subject" type="text" name="subject">
        <textarea class="txt_field" style="    color: #99a0aa;margin-top: 20px;  font: normal normal 16px/20px pnova-regular, helvetica, sans-serif; border: thin 1px; border-radius: 5px; border-color: white; width: 65%; height: 300px;" type="text" name="message">Message</textarea>
        <input style="margin-top: 20px; border: thin 1px; border-radius: 10px; border-color: white; cursor:pointer; background-color: #4db849; width:65%; height: 45px; color: white; font-weight: 700;" type="submit" value="Send Message">
        </form>
Pavan Jiwnani
  • 274
  • 1
  • 5