Support Forums

Full Version: [PHP] Why wont this work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
<?php
if (isset($_POST['email'])) {
mail("nbokmans@gmail.com", $_POST['email']);
    print_sent();
  }  else {
  getdata();
}

<BR></TD></TR></TABLE>
<div align="left"><font face="Comic Sans MS"><font size="2"><strong>After entering those fields, we will try to make contact with you as soon as possible. Your input is saved in our computer, and it won't be distributed to 3rd parties.<br /></strong></font></font></div>
<br />
<form onsubmit="return checkForm();" action="sitemail.php" method="post" name="post">

function checkForm() {
email = document.getElementById("email").value;

if (email == "") {
hideAllErrors();
document.getElementById("emailError").style.display = "none";
document.getElementById("email").select();
document.getElementById("email").focus();
return false;
}
return true;
}
</script>
function hideAllErrors() {
document.getElementById("emailError").style.display = "none"
}
function getdata() {
    <table height="610" cellspacing="3" cellpadding="0" width="380" border="0">
        <tbody>
            <tr>
                <td align="right" colspan="2">
                <p align="left"><font face="Comic Sans MS" size="2">Your Email <font color="#ff0000">*</font></font></p>
                </td>
                <td><input id="email" style="BACKGROUND-COLOR: #ffffff" maxlength="50" size="50" name="email" /> <font face="Comic Sans MS" size="2"></font>
                <div class="emailError" id="emailError"><br /><font face="Comic Sans MS" size="2">Error: Forgot to enter this field. Please enter your E-Mail to proceed.<br /></font></div>
            </tr>
  </tbody>
    </table>
</form>
<br />
                </TD>
}


?>

Please help, I've been stuck on it for 2 days. I don't know what I did wrong..
Well. You really should learn a more about PHP and javascript. You don't seem to know the difference between a server side script, and a client side script.
I've corrected your code, but it's still not really ... clear. I mean, this works, but it's still really dirty.

PHP Code:
<?php
if (isset($_POST['email'])) {
    
mail("nbokmans@gmail.com""subject",$_POST['email']);
    echo 
'
    <BR></TD></TR></TABLE>
    <div align="left"><font face="Comic Sans MS"><font size="2"><strong>After entering those fields, we will try to make contact with you as soon as possible. Your input is saved in our computer, and it won\'t be distributed to 3rd parties.<br /></strong></font></font></div>
    <br />    
    <script type="text/javascript">
    function checkForm() {
    email = document.getElementById("email").value;
    
    if (email == "") {
    hideAllErrors();
    document.getElementById("emailError").style.display = "none";
    document.getElementById("email").select();
    document.getElementById("email").focus();
    return false;
    }
    return true;
    }
    function hideAllErrors() {
    document.getElementById("emailError").style.display = "none"
    }
    '
;
}
else{
    echo 
'<table height="610" cellspacing="3" cellpadding="0" width="380" border="0">
        <tbody>
            <tr>
                <td align="right" colspan="2">
                <p align="left"><font face="Comic Sans MS" size="2">Your Email <font color="#ff0000">*</font></font></p>
                </td>
                <td>
                    <form onsubmit="return checkForm();" action="sitemail.php" method="post" name="post">
<input id="email" style="BACKGROUND-COLOR: #ffffff" maxlength="50" size="50" name="email" /> <font face="Comic Sans MS" size="2"></font>
                <div class="emailError" id="emailError"><br /><font face="Comic Sans MS" size="2">Error: Forgot to enter this field. Please enter your E-Mail to proceed.<br /></font></div>
                </form>
            </tr>
  </tbody>
    </table>
</form>
<br />
 </TD>
'
;
}
?>
I am not saying I am a PHP king, I just googled alot of things and tried putting them together. Thanks alot.