SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 42
  1. #1
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form Submit Problem

    When my form is filled out, and submit/send is hit the page flicks then returns back to the form page, with the form styles all incorrect. I'd like the form once complete to load another page or ID telling the user the message has been sent. (link)

  2. #2
    SitePoint Zealot auth1's Avatar
    Join Date
    Nov 2004
    Location
    Melbourne, Australia
    Posts
    167
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Not sure what you meant by the style is incorrect, I can't see a change on FF.

    As for displaying a message, you can do something like this:

    Code PHP:
    <?php
    if (count($_POST['submit'])>0) {
     echo "Form submitted";
    }
    ?>
    <form action="page.php" method="POST">
    etc

  3. #3
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    One thing I noticed is that you didn't close the script tag for "jquery.cycle.all.min.js" before or after submission.

    Then I ran your code through WinMerge to compare the code before and after. I attached the results. There are a number of differences...
    Attached Files Attached Files
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  4. #4
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Flowforce - I'm not following was I suppose to load the PHP file in a browser, because I did that and just a bunch of jargon came up !?!?!?

    Auth1 - there is a PHP file already, I would think it has it's own message upon sending, but instead the page goes wonky.

  5. #5
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    It's not a PHP file. It's an HTML file. Orange is where the code is different, which may be why your fields lose some of their styling.

    auth's approach is probably best, since the user probably won't need to re-visit the form after submission.

    Hint: you can submit to the same page--you don't have to submit to a separate page. That way, you won't have to maintain two sets of the same code, which seems to be where some of your problems may be surfacing.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  6. #6
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I renamed it to a HTML/HTM file this is all I see:

    PK����v>~ fp#-��s����differences.htm]{SF™wŠ>E’m˜iҦL%_t”’*qh†޽“„!Iž… ™`{o{V>—W-ɯž b˜ ›ƒc!W SŸQHg“O x`۳šYQ2~=> Ž ŠRf5.Ÿ>y&“Œu8%BdL Err&fq. rY9q<šŒ_zižBv’1#/€‘$ #8J3[~G|971‡R4•|jšOŸp{š/N7OŸXAH “8{œ fœD5(ˆ’ „H1˜?›y>g ƒ);4(t(–…a˜‘9'…TOI*h.9Vh›.Š:KB_ ››€?)I-#2%\&„dgkZ7c@…ˆ‚…‚zJe`?VW*I_SR_*$IGJ:]d :U٧ž’ԲO’XŽ.W[ٲOٰ$Œ )‰b}5%drUŽ@$–a›‹8%\&Œˆ†J:ž’  S’+jrK Nu(ž’ . S’+jrŽV„FJ%tbT’[A'J5etJa@W)^H sR I5t'ѝTDw„Nu ž’ :1)* cš2jZ;*;[Noe7•!„ ‚4ŽŽ/Œ!ŽK cƒiE9™dCœ/lˆ—0 y6*)$“8M CN)V ln\,ǻ\^’LŠ 7\jŒ/‰|™3!rEGqF…[( Bi€{žœNgƒp“/~^bŽ+c“”'‹1?f `—@š`@A* q™SU…‹6.JP#lL<u?užR/TžJCE
    Hint: you can submit to the same page--you don't have to submit to a separate page. That way, you won't have to maintain two sets of the same code, which seems to be where some of your problems may be surfacing.
    True, but where do I put auth code ?

  7. #7
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    The HTML file is inside the ZIP file. You don't need to rename it. If you're using Windows, there is native support for ZIP files.

    Quote Originally Posted by SiberianHuskey View Post
    True, but where do I put auth code ?
    I'm not clear on what your question is.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  8. #8
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WinMerge is a little difficult to differentiate between the code although nice how it works. FlowForce you mentioned to use Auth1 PHP code, where do I place it ?

    Edit:
    You've highlighted in yellow the changes but most of it is the same !?!?!

  9. #9
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by SiberianHuskey View Post
    WinMerge is a little difficult to differentiate between the code although nice how it works. FlowForce you mentioned to use Auth1 PHP code, where do I place it ?
    Ohhh...Auth1 is another user who posted in this thread. I was referring to his example code.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  10. #10
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I click 'submit' on my form the page re-loads and the styles are messed up. It was mentioned in this thread that I could load the 'sent' message on the same page, those are the two problems I want to know what is the cause of ? Currently no message is displayed when the 'submit' is triggered.

  11. #11
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    First, you're using two separate PHP files. It's not "re-loading" on an individual one. The link you provided is construction_site_G.php, which is submitted to construction_site.php. Is there a reason why you are doing it this way?

    The reason I posted a CSS/HTML comparison between those to pages is that one renders correctly, and the other doesn't, which was your original question. If both pages are identical and one renders correctly, but the other doesn't, then something has changed between them. The comparison file shows those differences.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  12. #12
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll re-check the styles, but on my current display is a little hard to notice between the two, do you have another method, maybe something online that I can distinguish easier ? As for what happens after the submit button is triggered, I'm not following ?

  13. #13
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by SiberianHuskey View Post
    I'll re-check the styles, but on my current display is a little hard to notice between the two, do you have another method, maybe something online that I can distinguish easier ? As for what happens after the submit button is triggered, I'm not following ?
    Go ahead and download and compare the generated HTML/CSS source with WinMerge yourself. The file I generated was supposed to make things easy to look at, but you may be able to view things easier through the actual application.

    As for your original question, I've attached screenshots for what I'm seeing in firefox before and after a submission. Is that what you're asking about?
    Attached Images Attached Images
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  14. #14
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As for your original question, I've attached screenshots for what I'm seeing in firefox before and after a submission. Is that what you're asking about?
    Yes, this is what I'm talking about. Shouldn't there be a page that loads that says your message has been sent ?

  15. #15
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    It depends on what your source code looks like. Go ahead and post it, otherwise we can't comment on it.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  16. #16
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML code or PHP, if HTML that is in message 1. If PHP then sure

  17. #17
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    I can already see your HTML source by going to view > source.

    PHP to see what's going on with your submission.

    And like I said before, you aren't submitting the page to itself, you're submitting it to a separate page. It's usually better for smaller applications to submit to itself.
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  18. #18
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Form PHP, yes there is HTML code within the PHP I don't understand !!!

    Code PHP:
    <?php 
    $your_email ='yourname@your-website.com';// <<=== update to your email address
     
    session_start();
    $errors = '';
    $name = '';
    $visitor_email = '';
    $user_message = '';
     
    if(isset($_POST['submit']))
    {
     
    	$name = $_POST['name'];
    	$visitor_email = $_POST['email'];
    	$user_message = $_POST['message'];
    	///------------Do Validations-------------
    	if(empty($name)||empty($visitor_email))
    	{
    		$errors .= "\n Name and Email are required fields. ";	
    	}
    	if(IsInjected($visitor_email))
    	{
    		$errors .= "\n Bad email value!";
    	}
    	if(empty($_SESSION['6_letters_code'] ) ||
    	  strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
    	{
    	//Note: the captcha code is compared case insensitively.
    	//if you want case sensitive match, update the check above to
    	// strcmp()
    		$errors .= "\n The captcha code does not match!";
    	}
     
    	if(empty($errors))
    	{
    		//send the email
    		$to = $your_email;
    		$subject="New form submission";
    		$from = $your_email;
    		$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     
    		$body = "A user  $name submitted the contact form:\n".
    		"Name: $name\n".
    		"Email: $visitor_email \n".
    		"Message: \n ".
    		"$user_message\n".
    		"IP: $ip\n";	
     
    		$headers = "From: $from \r\n";
    		$headers .= "Reply-To: $visitor_email \r\n";
     
    		mail($to, $subject, $body,$headers);
     
    		header('Location: thank-you.html');
    	}
    }
     
    // Function to validate against any email injection attempts
    function IsInjected($str)
    {
      $injections = array('(\n+)',
                  '(\r+)',
                  '(\t+)',
                  '(%0A+)',
                  '(%0D+)',
                  '(%08+)',
                  '(%09+)'
                  );
      $inject = join('|', $injections);
      $inject = "/$inject/i";
      if(preg_match($inject,$str))
        {
        return true;
      }
      else
        {
        return false;
      }
    }
    ?>
    Code HTML4Strict:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html>
    <head>
    	<title>Contact Us</title>
    <!-- define some style elements-->
    <style>
    label,a, body 
    {
    	font-family : Arial, Helvetica, sans-serif;
    	font-size : 12px; 
    }
    .err
    {
    	font-family : Verdana, Helvetica, sans-serif;
    	font-size : 12px;
    	color: red;
    }
    </style>	
    <!-- a helper script for vaidating the form-->
    <script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script>	
    </head>
     
    <body>
    <?php
    if(!empty($errors)){
    echo "<p class='err'>".nl2br($errors)."</p>";
    }
    ?>
    <div id='contact_form_errorloc' class='err'></div>
    <form method="POST" name="contact_form" 
    action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> 
    <p>
    <label for='name'>Name: </label><br>
    <input type="text" name="name" value='<?php echo htmlentities($name) ?>'>
    </p>
    <p>
    <label for='email'>Email: </label><br>
    <input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'>
    </p>
    <p>
    <label for='message'>Message:</label> <br>
    <textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea>
    </p>
    <p>
    <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
    <label for='message'>Enter the code above here :</label><br>
    <input id="6_letters_code" name="6_letters_code" type="text"><br>
    <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>
    </p>
    <input type="submit" value="Submit" name='submit'>
    </form>
    <script language="JavaScript">
    // Code for validating the form
    // Visit [url=http://www.javascript-coder.com/html-form/javascript-form-validation.phtml]JavaScript Form Validation : quick and easy![/url]
    // for details
    var frmvalidator  = new Validator("contact_form");
    //remove the following two lines if you like error message box popups
    frmvalidator.EnableOnPageErrorDisplaySingleBox();
    frmvalidator.EnableMsgsTogether();
     
    frmvalidator.addValidation("name","req","Please provide your name"); 
    frmvalidator.addValidation("email","req","Please provide your email"); 
    frmvalidator.addValidation("email","email","Please enter a valid email address"); 
    </script>
    <script language='JavaScript' type='text/javascript'>
    function refreshCaptcha()
    {
    	var img = document.images['captchaimg'];
    	img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
    }
    </script>
    <noscript>
    Code from the <a href='http://www.html-form-guide.com/contact-form/html-contact-form-captcha.html'
    >php contact form</a> article.
    </noscript>
    </body>
    </html>

  19. #19
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    And which file is this?
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  20. #20
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the PHP file that the form uses or supposedly uses.

  21. #21
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    As I mentioned before, you're showing two files.

    Quote Originally Posted by Force Flow View Post
    First, you're using two separate PHP files. It's not "re-loading" on an individual one. The link you provided is construction_site_G.php, which is submitted to construction_site.php. Is there a reason why you are doing it this way?
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  22. #22
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Confused !?!? How am I showing two files ??

  23. #23
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    The link you have at the top goes to /construction/construction_site_G.php

    However, when you submit the form, it goes to /construction/construction_sited.php

    The HTML code you are showing is for construction_sited.php (I'm guessing). However, that page just reloads itself. construction_site_G.php also goes to construction_sited.php.

    What is the file name that you got your PHP from?

  24. #24
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The link you have at the top goes to /construction/construction_site_G.php

    However, when you submit the form, it goes to /construction/construction_sited.php

    The HTML code you are showing is for construction_sited.php (I'm guessing). However, that page just reloads itself. construction_site_G.php also goes to construction_sited.php.
    Ahh I see now It's Fixed Now the page just reloads back to the form, nothing is displaying that the form was sent.

  25. #25
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Okay, good.

    Now, the second part: the file you gave us has no PHP. If it's going to load itself, that PHP needs to be in the form file.

    Put the PHP code you posted at the very top of the HTML file you posted, save that, upload it, and test it again.


Bookmarks

Posting Permissions

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