Current location: Hot Scripts Forums » Programming Languages » PHP » PHP form problem


PHP form problem

Reply
  #1 (permalink)  
Old 10-20-05, 06:27 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
PHP form problem

Hi there,

I'm kind of new here. Also I'm kind of new to PHP. I'm still learning.
I got a problem with a form I'm using.

If I filled it in and press the submit button it goed to a php page and stays there instead of going to the Thanx page.

I attached my html and php file.

Please help me out.

Greetz,

j
Attached Files
File Type: txt form.txt (8.1 KB, 413 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-20-05, 05:35 PM
xtremenw xtremenw is offline
Newbie Coder
 
Join Date: Dec 2004
Location: Tacoma, WA
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
With out digging to deep into the script, the fact that it is going to the thnx.html page is a good thing. It probably did everything it was supposed to. On the bottom of the file is:

Code:
	if (!mail($MailToAddress, $MailSubject, $mailMessage,$mailHeader)) \{ echo "Error sending e-mail!";\}\
	else \{ header("Location: ".$redirectURL); \}	\
If the script can not send the mail, echo "error...", else header("Location: ...");. The header() function is an internal PHP function. This funcation is mainly, from what i have seen, used for browser redirection.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-20-05, 08:36 PM
Richard's Avatar
Richard Richard is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Oxford, UK
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by xtremenw
With out digging to deep into the script, the fact that it is going to the thnx.html page is a good thing. It probably did everything it was supposed to. On the bottom of the file is:

Code:
	if (!mail($MailToAddress, $MailSubject, $mailMessage,$mailHeader)) \{ echo "Error sending e-mail!";\}\
	else \{ header("Location: ".$redirectURL); \}	\
If the script can not send the mail, echo "error...", else header("Location: ...");. The header() function is an internal PHP function. This funcation is mainly, from what i have seen, used for browser redirection.
The page isn't getting redirected to the thank you page, and I think its because of the code you've highlighted. Try removing the ! from the IF statement, then if the e-mailing is successful it will redirect to the $redirectURL (I'm assuming this is the thank you page).

Also, you're correct about the header() function, it is mainly used for brower redirection, although its basically able to send any raw HTTP header parameters, as pointed out here; PHP.net - header().
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-20-05, 09:40 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Quote:
Originally Posted by Richard
The page isn't getting redirected to the thank you page, and I think its because of the code you've highlighted. Try removing the ! from the IF statement, then if the e-mailing is successful it will redirect to the $redirectURL
Huh?

PHP Code:

if (!mail($MailToAddress$MailSubject$mailMessage,$mailHeader)) { echo "Error sending e-mail!"; }

else { 
header("Location: ".$redirectURL); } 
As it is written, if it fails it displays an error, else it spits out the thank you page.

If you remove the !, it will display an error when the mail() is successful, and the thank you page if it fails.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 10-20-05, 09:48 PM
jordie jordie is offline
Wannabe Coder
 
Join Date: Jun 2005
Posts: 179
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,

Firstly, where are you learning php from? You are using old methods... such as:
PHP Code:

while(list($key$val) = each($_GET)) { 

can now be replaced with
PHP Code:

foreach($_GET as $key=>$val) { 

also, try what richard said, swap the condition around AND also put a die(); after the header redirect cause the script still will run through after the header instruction:
PHP Code:

    if (mail($MailToAddress$MailSubject$mailMessage,$mailHeader)) { 

        
header("Location: ".$redirectURL);
                die();
    }
    else { 
         echo 
"Error sending e-mail!";
    } 
If it still isn't working, put a little debug test after the conditions closing brace like
PHP Code:

    if (mail($MailToAddress$MailSubject$mailMessage,$mailHeader)) { 

        
header("Location: ".$redirectURL);
                die();
    }
    else { 
         echo 
"Error sending e-mail!";
    }
echo 
"Testing 1 2 3..."
to see if the script is making it that far
__________________
Jordie Bodlay
php, mysql, postgres
css, xhtml
graphics, design
email me: jb2386@hotmail.com for any programming needs.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 10-21-05, 04:40 AM
Richard's Avatar
Richard Richard is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Oxford, UK
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Keith
Huh?

PHP Code:

if (!mail($MailToAddress$MailSubject$mailMessage,$mailHeader)) { echo "Error sending e-mail!"; }

else { 
header("Location: ".$redirectURL); } 
As it is written, if it fails it displays an error, else it spits out the thank you page.

If you remove the !, it will display an error when the mail() is successful, and the thank you page if it fails.
lol, completely ignore my post, I don't know what I was thinking to be honest. Maybe I shouldn't post so late, lol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 10-21-05, 04:51 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 704
Thanks: 0
Thanked 0 Times in 0 Posts
PHP form problems

I tried all of the given solutions, either none of them worked with me

- I removed the !
- changed the code fore what was given

but it didn't worked out :s


is there another solution??....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 11:17 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
PHP email form problem jcwilde1 PHP 2 06-19-05 12:19 AM
PHP script problem (please help) osmanmumtaz PHP 0 05-24-05 08:29 AM
Form Submission, PHP Coding Problem kibby67 PHP 3 12-02-04 02:13 PM


All times are GMT -5. The time now is 09:47 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.