MSUK1 Posted November 4, 2010 Share Posted November 4, 2010 so a user fills out a form, data gets sent to send.php then if successful redirects back to index.php, how on that index.php can i get it to say, sent successfully? Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/ Share on other sites More sharing options...
waynew Posted November 4, 2010 Share Posted November 4, 2010 After sending, redirect back to index with a GET variable such as header('Location: index.php?sent=Y'); Then on index.php if(isset($_GET['send']) && $_GET['send'] == "Y"){ echo 'Success'; } Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130466 Share on other sites More sharing options...
jcbones Posted November 4, 2010 Share Posted November 4, 2010 send.php //header redirect. header('Location: http://mydomain.com/index.php?sent=1'); index.php $message = NULL; if(isset($_GET['sent'])) { $message = 'Sent Successfully!'; } //decide on your message location, and echo the request. echo $message; *Warning - while you were typing a new reply has been posted. You may wish to review your post. * And it is amazingly similar. Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130467 Share on other sites More sharing options...
MSUK1 Posted November 4, 2010 Author Share Posted November 4, 2010 thankyou very much guys learning more everyday! Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130468 Share on other sites More sharing options...
MSUK1 Posted November 4, 2010 Author Share Posted November 4, 2010 sorry guys, if their was an error, i would return as ?sent=error but (using jcbones method) ?sent=ANYTHING returns the success code how could i add a seperate Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130471 Share on other sites More sharing options...
waynew Posted November 4, 2010 Share Posted November 4, 2010 You could change my code to: header('Location: index.php?sent=N'); if(isset($_GET['send']) && $_GET['send'] == "Y"){ echo 'Success'; } else if(isset($_GET['send']) && $_GET['send'] == "N"){ echo 'Error'; } Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130475 Share on other sites More sharing options...
MSUK1 Posted November 4, 2010 Author Share Posted November 4, 2010 with your method im finding a problem, this happens, http://msukgroup.co/Contact nothing now loads? however if you goto http://www.msukgroup.co/Contact/?send=Y it loads Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130476 Share on other sites More sharing options...
MSUK1 Posted November 4, 2010 Author Share Posted November 4, 2010 <?php $message = NULL; if(isset($_GET['send']) && $_GET['send'] == "Y"){ $message = '- Thankyou, we will reply within 24 Hours'; } else if(sset($_GET['send']) && $_GET['send'] == "N"){ $message = '- Sorry, an error occured please try again'; } ?> and then where i need the message displayed: <fieldset><legend>Online Form <?php echo $message; ?></legend> Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130478 Share on other sites More sharing options...
waynew Posted November 4, 2010 Share Posted November 4, 2010 I misspelled isset on the else if. Retry my code. Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130479 Share on other sites More sharing options...
MSUK1 Posted November 4, 2010 Author Share Posted November 4, 2010 no worries cant beleive i never noticed it, thankyou Link to comment https://forums.phpfreaks.com/topic/217795-question-about-after-a-script-is-executed/#findComment-1130481 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.