Results 1 to 5 of 5

Thread: Contact form does not work anymore?

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Arrow Contact form does not work anymore?

    It is always telling me "Please specify email" even if I fill up all the input boxes, I am not really sure how to debug it so I really need help in looking as to the reason why isset($_GET['empty_email']) is failing, this has been working on another host some years ago and I just uploaded it to a new host and it is not working.

    Code:
    <?php 
    
                                                    if(isset($_GET['empty_email'])) {
                                                        ?>Please specify email.<br />
        <?php
                                                    }
                                                    if(isset($_GET['invalid_email'])) {
                                                        ?>Incorrect email format.<br />
        <?php
                                                    }
                                                    if(isset($_GET['empty_captcha'])){
                                                        ?>Please specify verification code.<br />
        <?php 
                                                    } 
                                                    if(isset($_GET['wrong_code'])){ 
                                                        ?>Wrong verification code.<br />
        <?php 
                                                    }
                                                    if(isset($_GET['success'])){ 
                                                        ?>Comment successfully sent.<br />
        <?php 
                                                    }
    
                                                    ?>
    
        <form action="send_contact.php" method="post">
          <fieldset style="border: none;">
            <input type="hidden" name="submit" value="submit" />
    
            <p>Name:<br />
            <input type="text" maxlength="50" name="name" value="" /></p>
    
            <p>Email:<br />
            <input type="text" maxlength="50" name="email" value="" /></p>
    
            <p>Type verification image:<br />
            <input name="verif_box" type="text" id="verif_box" /> <img src="verificationimage.php?%3C?php%20echo%20rand(0,9999);?%3E" alt="verification image, type it in the box" width="50" height="24"
            align="bottom" /><br /></p>
    
            <p>Comments:<br />
            <textarea name="comments" rows="7" cols="7" style="width: 98%;">
    </textarea></p>
    
            <p><input type="submit" name="submit" value="Submit" /></p>
          </fieldset>
        </form>


    Code:
    <?php
    // Contact subject
    $subject ="comment"; 
    // Details
    $message="$comments"; 
    
    // Mail of sender
    $mail_from="$email"; 
    
    $validationOK=true;
    if (Trim($mail_from)=="") $validationOK=false;
    if (!$validationOK) {
    //	header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&empty_email=true");
    		header("Location: contact.php?subject={$subject}&from={$from}&message={$message}&empty_email=true");	
    		exit;
    }
    
    if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $mail_from)) { 
    //  echo "Valid email address."; 
    } 
    else { 
    		header("Location: contact.php?subject={$subject}&from={$from}&message={$message}&invalid_email=true");	
    		exit; 
    }
    
    
    // captcha
    $captcha="$verif_box"; 
    
    if (Trim($captcha)=="") $validationOK=false;
    if (!$validationOK) {
    	 //header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&empty_captcha=true");
    		header("Location: contact.php?subject={$subject}&from={$from}&message={$message}&empty_captcha=true");	
    		//print "<meta http-equiv=\"refresh\" content=\"0;URL=contactblankcaptcha.php\">";
      exit;
    }
    
    $verif_box = $_REQUEST["verif_box"];
    // From 
    $header="from: $name <$mail_from>"; 
    // Enter your email address
    $to ='[email protected]'; 
    
    if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
    	$send_contact=mail($to,$subject,$message,$header);
    	// delete the cookie so it cannot sent again by refreshing this page
    	setcookie('tntcon','');
    } else {
    	// if verification code was incorrect then return to contact page and show error
    	// header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true");
    	header("Location: contact.php?subject={$subject}&from={$from}&message={$message}&wrong_code=true");
    	exit;
    }
    
    // Check, if message sent to your email 
    // display message "We've recived your information"
    if($send_contact){
      //print "<meta http-equiv=\"refresh\" content=\"0;URL=contactsuccess.php\">";
    //  header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&success=true");
    		header("Location: contact.php?subject={$subject}&from={$from}&message={$message}&success=true");	
    }
    else {
    echo "ERROR";
    }
    ?>
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Contact form does not work anymore?

    From the looks of it the input values are not being passed to "send_contact.php", why is that? I am testing with echoing and it is always telling me blank for all the input values.

    Code:
    if (Trim("$name")=="") 
    { ECHO "blank!!"; }
    else
    { ECHO "not blank!!"; }
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Contact form does not work anymore?

    you never define $email.
    Like Archer? Check out some Sterling Archer quotes.

  4. #4

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Contact form does not work anymore?

    Doesn't that comes from this "email" input?

    Code:
    <input type="text" maxlength="50" name="email" value="" /></p>
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Contact form does not work anymore?

    When you submit a form, the values are accessible in PHP through either the $_POST or the $_GET collection, depending on which one you specified as "method" in your form tag:
    Code:
     <form action="send_contact.php" method="post">
    You're using post, so to access the value of:
    Code:
    <input type="text" maxlength="50" name="email" value="" />
    ...you need to look at $_POST["email"]. Same goes for all form inputs.

    It sounds like your former host probably had register_globals turned on, which is a huge potential security problem.

Posting Permissions

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



Click Here to Expand Forum to Full Width