Hi,
Don’t give me the answer to this query… just point me in the right direction. I’d like to figure it out myself…
I have a form. It’s on my form.php page. It’s “action” sends the data to a formdata.php page where it’s displayed (works fine). Also, when the user clicks on the submit button, they’re taken to the “Thank You” page (also works fine).
The words “Thank You” display just fine but I want them to say: “Thank You + [the person’s first name]”.
I’ve looked high and low on the net… can’t find the answer that works. I’ve tried different combinations of:
$fname = $_POST[‘fname’]; and
echo "First Name: " . $fname;
in the thankyou.php page code. What am I missing? Do I have to add a link href tag in the head? What?
Thanks.
How does the user get to the thank you page if the form action is going to formdata? is it a header redirect on the formdata page?
If the form data is being sent to fordata.php then it may not exist on the thank you page.
My tip would be to merge the formdata and thank you pages into one. This way you’re not battling with carrying form variables all over the place.
I don’t want the form data listed on the thank you page… considered it but don’t want it.
The user is sent to the thank you page when they click on the submit button. I use the “onclick” function: onclick=“window.open…”.
The action function sends the data to my data page independently of the 'onclick" function attached to the submit button.
That raises another issue. In additon to sending the data to the data page, and sending the user to the thankyou page, I also want to be notified via email that someone has filled out the form.
I use the “onclick” function: onclick=“window.open…”.
So the only way I can see that you’d be able to get the user’s name (from the form) would be to use the querystring.
//in your onclick funtion
var username = document.getElementById('username').value;
window.open('thankyou.php?name=' + username);
As for the email notification simply create an email script in your formdata.php page PHP mail() Function
I want the answer! That would be something cool I would add to my site. My thank you page is a completely different page so prob no go.
As Javascript stated, tack the name onto the end of the window.open call as a parameter. window.open acts as a new URL call, so thankyou.php can find the name in the $_GET array.
As is, that’s over my head. I would need to see where to put all those goodies.
So if you did something like…
<script type='text\\javascript'>
function [COLOR="RoyalBlue"]doSomething()[/COLOR] {
var username = document.getElementById('[COLOR="Purple"]username[/COLOR]').value;
window.open('[COLOR="SandyBrown"]thankyou.php[/COLOR]?[COLOR="SeaGreen"]name[/COLOR]=' + username);
}
</script>
<input id='[COLOR="Purple"]username[/COLOR]' type='text'>
<img src='blahdeblah.jpg' onclick='[COLOR="RoyalBlue"]doSomething()[/COLOR]'>
and then thankyou.php:
<?php
echo "Thank You ".$_GET['[COLOR="SeaGreen"]name[/COLOR]'];
?>
EDIT: Now I get my crayons out to show the relevant linking parts…
Cool thank you I will give that a go…