vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   php contact form help redirecting to a thank you page (https://vborg.vbsupport.ru/showthread.php?t=206375)

tipoboy 02-23-2009 08:44 PM

php contact form help redirecting to a thank you page
 
hi there i am using a php page as a contact form, the code is:

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if(isset($_POST['submit'])){
//GET ALL FORM INFO INTO VARIABLES
$name = $_POST['name'];
$SAFEname = htmlentities($name);
$email = $_POST['email'];
$SAFEemail = htmlentities($email);
$contactnumber = $_POST['contactnumber'];
$SAFEcontactnumber = htmlentities($contactnumber);
$subject = $_POST['subject'];
$SAFEsubject = htmlentities($subject);
$message = $_POST['message'];
$SAFEmessage = htmlentities($message);
$to = 'enquiries@mysite.co.uk';
$subject = 'Contact Forrm';
$msg = "Name: ".$SAFEname."\nEmail: ".$SAFEemail."\nContact Number: ".$SAFEcontactnumber."\nSubject: ".$SAFEsubject."\nMessage: ".$SAFEmessage."\n";
$headers = "From: ".$SAFEemail."\nReply-To: ".$SAFEemail."\nReturn-Path: ".$SAFEemail."\n"; 
 
if($SAFEname != "" && $SAFEmessage != ""){
 mail($to, $subject, $msg, $headers);
 echo "<fieldset><legend>Thank You&nbsp;&nbsp;</legend>Thank you for emailing us, please allow up to 48 hours for a reply! Very occasionally it may take longer to reply, please be patient with us If you have not had a reply within 7 days please feel free to email again!</fieldset>";
} else {
 echo "<fieldset><legend>Error&nbsp;&nbsp;</legend>Please fill in all requires fields, thank you.</fieldset>";
}} 
?>
<html>
<head>
<title>Contact Page</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
 
<table id="main" width="660" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td width="790"><img src="images/baner.gif" alt="welcome" width="385" height="65"></td>
  </tr>
    <tr>
    <td><table width="650" border="0">
        <tr>
          <td class="navigation" width="120" rowspan="2" valign="top">
  <?php
  require("navigation.php")
  ?>
    </td>
          <td><p class="heading">::: welcome :::</p><hr width="90%"></td>
 
        </tr>
        <tr>
          <td><fieldset>
        <legend>Contact Us&nbsp;&nbsp;</legend>
        <form method="post" action="contactus.php">
              <table width="500" border="0" cellpadding="5" cellspacing="5" class="contact">
                <tr>
                  <td colspan="2"><p class="second"><font color="#FF0000">All
                      fields are required to be filled otherwise an error will
                      occur, thank you</font></p></td>
                </tr>
                <tr>
                  <td class="contact">Name:</td>
                  <td class="contactinput"><input name="name" type="text" size="25" maxlength="50">
                    <font color="#FF0000" size="1"><em>*required</em> </font></td>
                </tr>
                <tr>
                  <td class="contact">Email:</td>
                  <td class="contactinput"><input name="email" type="text" size="25" maxlength="100">
                    <font color="#FF0000" size="1"><em>*required</em> </font></td>
                </tr>
 
                <tr>
                  <td class="contact">Contact Number:</td>
                  <td class="contactinput"><input name="contactnumber" type="text" size="25" maxlength="20">
                    <font color="#FF0000" size="1"><em>*required</em> </font></td>
                </tr>
                <tr>
                  <td class="contact">Subject:</td>
                  <td class="contactinput"><select name="cusubject" id="cusubject">
                      <option>Please Select From The Following:</option>
                      <option>E-mail a Question</option>
                      <option>Request a Price List</option>
                      <option>Request More Information</option>
                      <option>New Year Reel Information</option>
                      <option>Other</option>
                    </select> <font color="#FF0000" size="1"><em>*required</em>
                    </font></td>
                </tr>
                <tr>
                  <td class="contact">Message:</td>
                  <td class="contactinput"><textarea name="message" cols="27" rows="5" id="message"></textarea>
                    <font color="#FF0000" size="1"><em>*required</em> </font></td>
                </tr>
                <tr>
                  <td></td>
                  <td class="contactinput"><input name="submit" type="submit" value="Send message" class="submit"></td>
                </tr>
              </table>
        </form>
</fieldset><br>
          </td>
        </tr>
      </table></td>
  </tr>
  <tr>
  <td class="copyright" height="21" colspan="3"><br>
      <?php
require("copyright.php");
?>
      </td>
  </tr>
</table>
</body>
</html>

what i'd like to do is instead of using text in a fieldset with the thank you or error outputs, i'd like to link to a thank you page and an error page, am in the process of trying to learn some php and any assistance is grately appreciated:)

ta very much
dave

TigerC10 02-23-2009 08:56 PM

Wow... Didn't look down the list of threads in this area? I mean, it's right there on the first page.

https://vborg.vbsupport.ru/showthread.php?t=206347

tipoboy 02-23-2009 09:14 PM

Quote:

Originally Posted by TigerC10 (Post 1752673)
Wow... Didn't look down the list of threads in this area? I mean, it's right there on the first page.

https://vborg.vbsupport.ru/showthread.php?t=206347

hmm i see you didnt read the whole question, i did read that post however and tried the
Code:

header("Location: http://www.example.com/");
but when i tried it i got an error at the top of my page saying

Code:

Warning: Cannot modify header information - headers already sent by (output started at /home/*******/public_html/mysite.co.uk/contactus.php:2) in /home/*******/public_html/mysite.co.uk/contactus.php on line 28
so my question i asked was how i could, when my submit button is pressed and everything is filled in corretly and fine i get the thankyou.php page

but if there is an error i get directed tio an error.php page

but thank you for your reply either way

TigerC10 02-23-2009 10:27 PM

Did you do the last post I gave in that thread? Using the ob_end_flush() function?

Dismounted 02-24-2009 04:09 AM

You must have no output before running that PHP code. You have this at the top of the page (and is considered output):
HTML Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

tipoboy 02-24-2009 06:29 AM

Quote:

Originally Posted by TigerC10 (Post 1752745)
Did you do the last post I gave in that thread? Using the ob_end_flush() function?

no i never tried that, but dismounted's suggestion of moving the doctype has worked thanks for the help anywayz :)

Quote:

Originally Posted by Dismounted (Post 1752964)
You must have no output before running that PHP code. You have this at the top of the page (and is considered output):
HTML Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

thanks dismounted thats worked, got it working now:)

TigerC10 02-24-2009 05:24 PM

Quote:

Originally Posted by tipoboy (Post 1753091)
no i never tried that, but dismounted's suggestion of moving the doctype has worked thanks for the help anywayz :)

That's why I suggested using ob_end_flush(). Using that function allows you to have output before doing the redirect.


All times are GMT. The time now is 09:01 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01641 seconds
  • Memory Usage 1,753KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_html_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete