www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: [RESOLVED] Form Values Not submitting between pages...

  1. #1
    Join Date
    Jun 2003
    Posts
    72

    resolved [RESOLVED] Form Values Not submitting between pages...

    I have a web form, that I am trying to process and send to an email address... but the variables are not being transfered between the pages. Can someone help me figure out why?

    I tried REALLY simplifying the code, but it still didn't work. It's obviously something to do with the initial form (take a look below), or something wrong with the server transfering variables (if this is the case, what do I ask my webhost?) ....

    Below is the complete code (minus the javascript for form validation ... which should not affect the variables transferring between pages)

    Initial form for submission....
    Code:
    <div class="side-formbox">
                        
                  <form name="contact_form" method="post" action="contactform.php" onSubmit="return evalid()">
                        
                            <div class="formlabel"> Name *</div>
                			<div class="formfield"><input name="fname" type="text" /></div>
                        
                            <div class="formlabel"> E-mail *</div>
                            <div class="formfield"><input type="text" name="mail" size="30" /></div>
                        
                            <div class="formlabel">Phone</div>
                            <div class="formfield"><input name="phone" type="text" size="30" onkeypress="return numere(event)" onkeyup="return limitarelungime(this, 10)"  /></div>
                        
                            <div class="formlabel">Message *</div>
                            <div class="formfield"><textarea name="message" onkeyup="return limitarelungime(this, 255)" rows="5"></textarea></div>
                        
                            <div class="formlabel">Security Code*</div>
                            <div class="formcode"><input id="chapcha_code" name="chapcha_code" type="text" /></div>
                            <div class="formcodeimg"><img src="security_image.php" border="0" /></div>
                            <div class="clear"></div>
                        
                            <div class="formlabel">
                            <!-- <input type="reset" name="reset" value="Reset"/> -->
                                <input type="submit" name="Submit" value="Submit" id="Submit">
                            </div>
                        
                  </form>
                </div>
    Code from the processing page (contactform.php)...
    Code:
    <?php session_start(); ?>
    
    <!-- Head tag, title, and then the start of the body tag and some content -->
     
    <?php
    
    echo "submitPOST: ".$_POST['Submit']."<br /><br />";
    echo "messagePOST: ".$_POST['message']."<br /><br />";
    echo "messageGET: ".$_GET['message']."<br /><br />";
    
    // These three variables (above) output empty results, 
    // even when I put in a value and submit it .....
    // So, without any values for these, the rest of 
    // the form doesn't really work.
    
    if(isset($_POST['Submit'])) {   
    	if( $_SESSION['chapcha_code'] == $_POST['chapcha_code'] && !empty($_SESSION['chapcha_code'] ) ) {
    		
    		$youremail = 'test@mydomain.com';
    		$fromsubject = 'Form Contact Page';
    		$title = $_POST['title'];
    		$fname = $_POST['fname'];
    		$mail = $_POST['mail'];
    		$phone = $_POST['phone']; 
    		$message = $_POST['message']; 
    			$to = $youremail; 
    			$mailsubject = 'Form Contact Page';
    			$body = $fromsubject.'
    			
    			 Name:  '.$fname.'
    			 Phone Number: '.$phone.'
    			 E-mail: '.$mail.'
    			
    			 Message: 
    			 '.$message.'
    			
    			|---------END MESSAGE----------|'; 
    	
    		echo "Thank you fo your message. Someone will contact you shortly."; 
    		mail($to, $subject, $body);
    		unset($_SESSION['chapcha_code']);
       } else {
    		echo 'Sorry, you have provided an invalid security code<br /><br />';
    		?>
    
                        
         				 <form name="contact_form" method="post" action="contactform.php" onSubmit="return evalid()">
                        
                            <div class="formlabel">Name *</div>
    						<div class="formfield"><input name="fname" type="text" /></div>
                        
                            <div class="formlabel">E-mail *</div>
                            <div class="formfield"><input type="text" name="mail" size="30" /></div>
                        
                            <div class="formlabel">Phone</div>
                            <div class="formfield"><input name="phone" type="text" size="30" onkeypress="return numere(event)" 
                            		onkeyup="return limitarelungime(this, 10)"  /></div>
                        
                            <div class="formlabel">Message *</div>
                            <div class="formfield"><textarea name="message" onkeyup="return limitarelungime(this, 255)"  cols="35" rows="5"></textarea></div>
                        
                            <div class="formlabel">Security Code*</div>
                            <div class="formcode"><input id="chapcha_code" name="chapcha_code" type="text" /></div>
                            <div class="formcodeimg"><img src="security_image.php" border="0" /></div>
                        	<div class="clear"></div>
                            
                            <div class="formlabel">
                            <!-- <input type="reset" name="reset" value="Reset"/> -->
                                <input type="submit" name="Submit" value="Submit" id="Submit">
                            </div>
                        
         				 </form>
    
            <?php
       }
    } else { 
    	echo "You must write a message. </br> Please go to <a href='/contact.php'>Contact Page</a>"; 
    	echo $message;
    }
    ?>
    Please help ... I've tried 3 different types of email submission forms ... and they all had the same problems...

  2. #2
    Join Date
    Jan 2004
    Posts
    484
    form action is = post

    Don't use $_GET

    use $_POST

    rename your submit button to 'submitted' as 'submit' is a reserved word

  3. #3
    Join Date
    Jun 2003
    Posts
    72
    That didn't do it. The reason I also tried GET was because POST wasn't working. Wanted to see if that would work too....

    Also the SUBMITTED didn't work. (plenty of online examples use "submit" in their code ... and plenty of people say their code works)


    Code:
    <form name="contact_form" method="post" action="contactform.php" onSubmit="return evalid()">
                        
                            <div class="formlabel"> Name *</div>
                			<div class="formfield"><input name="fname" type="text" /></div>
                        
                            <div class="formlabel"> E-mail *</div>
                            <div class="formfield"><input type="text" name="mail" size="30" /></div>
                        
                            <div class="formlabel">Phone</div>
                            <div class="formfield"><input name="phone" type="text" size="30" onkeypress="return numere(event)" onkeyup="return limitarelungime(this, 10)"  /></div>
                        
                            <div class="formlabel">Message *</div>
                            <div class="formfield"><textarea name="message" onkeyup="return limitarelungime(this, 255)" rows="5"></textarea></div>
                        
                            <div class="formlabel">Security Code*</div>
                            <div class="formcode"><input id="chapcha_code" name="chapcha_code" type="text" /></div>
                            <div class="formcodeimg"><img src="security_image.php" border="0" /></div>
                            <div class="clear"></div>
                        
                            <div class="formlabel">
                            <!-- <input type="reset" name="reset" value="Reset"/> -->
                                <input type="submit" name="Submitted" value="Submit" id="Submitted">
                            </div>
                        
                  </form>

    And the processing page...
    Code:
    <?php
    echo "messagePOST: ".$_POST['message']."<br /><br />";
    if(isset($_POST['Submitted'])) {   
    	if( $_SESSION['chapcha_code'] == $_POST['chapcha_code'] && !empty($_SESSION['chapcha_code'] ) ) {
    		
    		$youremail = 'test@rapaportlaw.com';
    		$fromsubject = 'Rapaport Law Contact Page';
    		$title = $_POST['title'];
    		$fname = $_POST['fname'];
    		$mail = $_POST['mail'];
    		$phone = $_POST['phone']; 
    		$message = $_POST['message']; 
    			$to = $youremail; 
    			$mailsubject = 'Rapaport Law Contact Page';
    			$body = $fromsubject.'
    			
    			 Name:  '.$fname.'
    			 Phone Number: '.$phone.'
    			 E-mail: '.$mail.'
    			
    			 Message: 
    			 '.$message.'
    			
    			|---------END MESSAGE----------|'; 
    	
    		echo "Thank you fo your message. Someone will contact you shortly.<br/>Return to our <a href='http://www.rapaportlaw.com/'>Home Page</a>"; 
    		mail($to, $subject, $body);
    		unset($_SESSION['chapcha_code']);
       } else {
    		echo 'Sorry, you have provided an invalid security code<br /><br />';
    		?>
                        
         				 <form name="contact_form" method="post" action="contactform.php" onSubmit="return evalid()">
                        
                            <div class="formlabel">Name *</div>
    						<div class="formfield"><input name="fname" type="text" /></div>
                        
                            <div class="formlabel">E-mail *</div>
                            <div class="formfield"><input type="text" name="mail" size="30" /></div>
                        
                            <div class="formlabel">Phone</div>
                            <div class="formfield"><input name="phone" type="text" size="30" onkeypress="return numere(event)" 
                            		onkeyup="return limitarelungime(this, 10)"  /></div>
                        
                            <div class="formlabel">Message *</div>
                            <div class="formfield"><textarea name="message" onkeyup="return limitarelungime(this, 255)"  cols="35" rows="5"></textarea></div>
                        
                            <div class="formlabel">Security Code*</div>
                            <div class="formcode"><input id="chapcha_code" name="chapcha_code" type="text" /></div>
                            <div class="formcodeimg"><img src="security_image.php" border="0" /></div>
                        	<div class="clear"></div>
                            
                            <div class="formlabel">
                            <!-- <input type="reset" name="reset" value="Reset"/> -->
                                <input type="submit" name="Submitted" value="Submit" id="Submitted">
                            </div>
                        
         				 </form>
    
            <?php
       }
    } else { 
    	echo "You must write a message. </br> Please go to <a href='/contact.php'>Contact Page</a>"; 
    	echo $message;
    }
    ?>

  4. #4
    Join Date
    Jan 2004
    Posts
    484
    okay so here is a simple test I did and it passed

    I notice you don't have a title

    PHP Code:

    <?php

    if(isset($_POST['submitted'])){
        
        echo 
    "messagePOST: ".$_POST['message']."<br /><br />";
        echo 
    "chapcha_codePOST: ".$_POST['chapcha_code']."<br /><br />";
        
    //echo "titlePOST: ".$_POST['title']."<br /><br />";
        
    echo "fnamePOST: ".$_POST['fname']."<br /><br />";
        echo 
    "mailPOST: ".$_POST['mail']."<br /><br />";
        echo 
    "phonePOST: ".$_POST['phone']."<br /><br />";

    }else {    



    ?




    <!
    DOCTYPE html >
    <
    html>

        <
    head>

            <
    title>HTML Template</title>

        </
    head>

        <
    body>
        
                <
    form name="contact_form" method="post" actiophp">
                        
                            <div class="
    formlabel"> Name *</div>
                            <div class="
    formfield">
                                <input name="
    fname" type="text" />
                            </div>
                        
                            <div class="
    formlabel"> E-mail *</div>
                            <div class="
    formfield">
                                <input type="
    text" name="mail" size="30" />
                            </div>
                        
                            <div class="
    formlabel">Phone</div>
                            <div class="
    formfield">
                                <input name="
    phone" type="text" size="30" />
                            </div>
                        
                            <div class="
    formlabel">Message *</div>
                            <div class="
    formfield"><textarea name="message" rows="5"></textarea>
                            </div>
                        
                            <div class="
    formlabel">Security Code*</div>
                            <div class="
    formcode"><input id="chapcha_code" name="chapcha_code" type="text" /></div>
                            <div class="
    clear"></div>
                        
                            <div class="
    formlabel">
                            <!-- <input type="
    reset" name="reset" value="Reset"/> -->
                                <input type="
    submit" name="submitted" value="submit" id="submitted">
                            </div>
                        
                  </form>

        </body>
    </html>
    <?
    }
    ?>

  5. #5
    Join Date
    Jun 2003
    Posts
    72
    That wouldn't cause the other variables not to go through.

    Either way, I removed that line, and it still only outputted


    messagePOST:

    You must write a message.
    Please go to Contact Page
    Variables are still not going through...

  6. #6
    Join Date
    Jan 2004
    Posts
    484
    Can I see your folder structure.

  7. #7
    Join Date
    Jun 2003
    Posts
    72
    The files are all in the same folder....

    I just tested the files on another server, and the variables were being sent fine.

    So, its a server issue. Any idea what setting needs to be change, and how I go about doing it? Need to know what to ask/tell my webhost.

  8. #8
    Join Date
    Jan 2004
    Posts
    484
    what are you running on?

  9. #9
    Join Date
    Jan 2004
    Posts
    484
    is there a redirect in play?

  10. #10
    Join Date
    Jun 2003
    Posts
    72
    No redirect that I know of. Not sure what the server settings are .... its just the server that my friend gave me.

    I'll check...

  11. #11
    Join Date
    Jun 2003
    Posts
    72
    I don't know much about server settings and PHP configuration ... but is it possible global variables are turned off?

  12. #12
    Join Date
    Aug 2012
    Location
    Programming
    Posts
    21
    Can you add the code in the server. I'll look.

    Cap123

  13. #13
    Join Date
    Mar 2012
    Posts
    1,741
    I'd recommend setting up WAMP as a local host. It is pre-configured. It even works across a local network.

  14. #14
    Join Date
    May 2010
    Location
    Effingham, IL
    Posts
    87

    Suggestion

    May I make a suggestion?

    I would combine your processing page and your form together. You would set your form to run $_SERVER['PHP_SELF]; This will allow you to input data back into any fields that were filled in and highlight fields that need filled, etc. Returning a blank form may make people think it went through or it doesn't work.

  15. #15
    Join Date
    Jun 2003
    Posts
    72
    Cap123 - Take a look ... you wont be able to see much from the front end. http://rapaportlaw.com/newsite/areas...t-overview.php (the form is in the bottom right). You can see it working on my own server http://djgallagher.com/_test/page_with_side.php (note: the MessagePOST varibale gets transferred at the top of the page)

    rebelweb2007 - Your suggestion didn't work. When the form is submitted on the same page, the page reloads and the variables still do not get transferred.

    jedaisoul - WAMP? You are going way beyond my knowledge. This is a hosted account with my client, they wont be into moving to a new server ... and it's an account hosted with Godaddy, so they do not allow for much flexibility with changing server settings (I hate them)
    Last edited by jabbamonkey; 09-05-2012 at 08:52 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles