Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PHP] Why wont this work?
#1
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..
Reply
#2
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>
'
;
}
?>
Reply
#3
I am not saying I am a PHP king, I just googled alot of things and tried putting them together. Thanks alot.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 789 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP email input form - having trouble getting the form to work... abayindi 4 2,429 03-19-2012, 10:02 AM
Last Post: RainbowDashFTW
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,313 10-10-2011, 01:00 PM
Last Post: Greyersting

Forum Jump:


Users browsing this thread: 1 Guest(s)