Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2009, 08:44 PM
tipoboy's Avatar
tipoboy tipoboy is offline
 
Join Date: Dec 2005
Location: scotland
Posts: 693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 02-23-2009, 08:56 PM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #3  
Old 02-23-2009, 09:14 PM
tipoboy's Avatar
tipoboy tipoboy is offline
 
Join Date: Dec 2005
Location: scotland
Posts: 693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TigerC10 View Post
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
Reply With Quote
  #4  
Old 02-23-2009, 10:27 PM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you do the last post I gave in that thread? Using the ob_end_flush() function?
Reply With Quote
  #5  
Old 02-24-2009, 04:09 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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">
Reply With Quote
  #6  
Old 02-24-2009, 06:29 AM
tipoboy's Avatar
tipoboy tipoboy is offline
 
Join Date: Dec 2005
Location: scotland
Posts: 693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TigerC10 View Post
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 View Post
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
Reply With Quote
  #7  
Old 02-24-2009, 05:24 PM
TigerC10's Avatar
TigerC10 TigerC10 is offline
 
Join Date: Apr 2006
Location: Austin, TX
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tipoboy View Post
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05388 seconds
  • Memory Usage 2,241KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_html
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete