Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    email sending error

    i have this script but when i click on submit button it goes to the php file to send email. but it always reflect "blarg!" anyone know why?

    http://www.pddesignstudio.com/ckc/testError.html

    [HTML]<style type="text/css">
    </style>
    </head>
    <body>

    <script type="text/javascript" src="clientscript/vbulletin_md5.js?v=384"></script>
    <script type="text/javascript">
    function verify_names(name)
    {
    // do various checks, this will save people noticing mistakes on next page
    if (name.value == '')
    {
    alert('Please fill out name fields.');
    return false;
    }
    else
    {
    var junk_output;

    md5hash(name1, document.forms.register.name_md5, junk_output, 0);

    return true;
    }
    return false;
    }
    </script>

    <form action="mailer1.php" name="register" method="post" onsubmit="return verify_names(name);">

    <input type="hidden" name="name_md5" />

    Name:<br />
    <input type="text" name="name" size="25" />

    <div style="margin-top:6px">
    <input type="submit" class="button" value="submit"/>
    </div>

    </form>
    <br />
    </div>[/HTML]

    php code
    Code:
    <?php
    if(isset($_POST['submit'])) {
    
    	$to = "szething@pddesignstudio.com"; 
    	$subject = "CKC CONTACT FORM";
    	$headers = "From: ";
    	$headers .= $_POST['email'];
    	
    	foreach($_POST['check'] as $value) {
    		$check_msg .= "Checked: $value\n";
    	}
    	
    	$body = "Name: $name_field\n";
    
    	echo "Data has been submitted to $to!";
    	mail($to, $subject, $body, $headers);
    	
    } else {
    	echo "blarg!";
    }
    ?>

  • #2
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    look at this

    PHP Code:
    } else {
        echo 
    "blarg!";

    its outputting blarg due to the following statement is NOT true:
    PHP Code:
    if(isset($_POST['submit'])) { 
    change

    Code:
    <input type="submit" class="button" value="submit"/>
    to
    Code:
    <input type="submit" class="button" name="submit" value="submit"/>
    Last edited by Phil Jackson; 08-27-2009 at 08:30 AM.

  • #3
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You forgot the name tag to be set in your submit button.

    Zac
    __________________
    PHP Developer
    www.mycodeteacher.com
    Last edited by zcarter; 08-27-2009 at 11:23 AM.

  • #4
    Senior Coder
    Join Date
    Aug 2009
    Location
    Mansfield, Nottinghamshire, UK
    Posts
    1,555
    Thanks
    57
    Thanked 148 Times in 147 Posts
    ... as stated previously


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •