Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Directory Submission Service   I Sell Pagerank   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 07-23-2007, 05:51 AM   #1 (permalink)
Inactive
 
Join Date: 07-19-07
Location: wales
Posts: 57
iTrader: 0 / 0%
Latest Blog:
None

chloew is liked by many
Help with a submission form in php

Hi can anyone help me with making a submission form in php.
I have done most of it but i am stuck with once someone presses the submit button to send the request, the email comes to me as it should but i would also like the submission page to move to another page that says something like "thanks for your enquiry" but i dion't know how to do this, can someone write the code that i am missing to help me out with this.
Thanks very much
chloew is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 07-24-2007, 10:48 AM   #2 (permalink)
Contributing Member
 
LiamSwan's Avatar
 
Join Date: 07-24-07
Posts: 132
iTrader: 0 / 0%
Latest Blog:
None

LiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really nice
Your form page should contain this

Code:
<form method="post" action="contact.php"> form fields </form>
create a contact.php page in the same directory with the following code

PHP Code:
<?php

$EmailTo 
"something@yourwebsite.com";
$xxxxx Trim(stripslashes($_POST['xxxxx'])); 


// validation
$validationOK=true;
if (!
$validationOK) {
  print 
"<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body "";
$Body .= "xxxxx: ";
$Body .= $xxxxx;
$Body .= "\n";

// send email 
$success mail($EmailTo$xxxxx$Body);

?>

You should already have this. xxxxx being one of the fields, you probably have many more.
Anyway, simply add the following before the last ?>

PHP Code:
// redirect to success page 
if ($success){
  print 
"<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
  print 
"<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";

create the ok.htm page to your liking, this is the page the user is taken to after submiting the form.
It's also smart to creat an error.htm page that redirects a user to an error page if the form failed to send for any reason.
LiamSwan is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-25-2007, 03:36 AM   #3 (permalink)
Inactive
 
Join Date: 07-02-07
Posts: 168
iTrader: 0 / 0%
webprofession is liked by many
Quote:
Originally Posted by LiamSwan View Post
PHP Code:
// validation
$validationOK=true;
if (!
$validationOK) {
  print 
"<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;

Right code, but
I think, there is no need of this code.
webprofession is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-25-2007, 05:05 AM   #4 (permalink)
Contributing Member
 
LiamSwan's Avatar
 
Join Date: 07-24-07
Posts: 132
iTrader: 0 / 0%
Latest Blog:
None

LiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really niceLiamSwan is just really nice
Well that depends. He may want to have a field that 'must' be filled. In which case he would need that bit of code to validate that field entry, like 'email' or 'name' fields.
LiamSwan is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-26-2007, 05:37 AM   #5 (permalink)
Inactive
 
Join Date: 07-19-07
Location: wales
Posts: 57
iTrader: 0 / 0%
Latest Blog:
None

chloew is liked by many
Thanks the code was perfect i did pick out only the pieces i needed as i had already used most of them.
Thanks again
chloew is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-27-2007, 07:21 PM   #6 (permalink)
v7n Goddess
 
Tanya's Avatar
 
Join Date: 09-24-06
Location: Where I Belong
Posts: 3,331
iTrader: 3 / 100%
Tanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest orderTanya is a web professional of the highest order
Liam u big hunk of coding man you LOl!
add a damn avatar already or else...

__________________
Design Pride- A Breast Cancer Awareness Theme <-- Check it out!!
A guy, a girl, and a blog - My new fav blog to read, so funny in a nasty way!!!
Tanya is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-29-2007, 07:04 PM   #7 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 17,965
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
Moved to coding.
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
chıcgeeĸ @ flickr
chicgeek is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't show non-modal form when modal form is displayed sypond Coding Forum 3 03-23-2007 08:31 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 05:12 AM.
© Copyright 2008 V7 Inc