Hello
I am a pesky beginner. I create websites using Lauyan WYSIWYG software but sometimes I need to use more complex functions. For the moment I've managed by copying bits of scripts and adaping them but this time I've run into a brick wall. And I am sure it should be easy and all my tries have probably failed for syntax error or a missing var or something.
So I really would appreciate somebody to take me slowly through this one.
I am making a site for a travel agency. On each page (over 150) there should be a contact form which should include the tour name or code the person is interested in.
Rather than creating (and maintaining) 150 contact forms what I would like to do ideally is : keep the 150 pages but add a button to a common "Booking & Enquiries" form. So far that's OK. But I would like the form to have a hidden field with a variable value. This value could just be the URL of the sending page. I can display the value of the current URL with window.location and put it in a var.
Now I just need how to know how to put it in the wg-formfield
anyways, using php, after submitting your first form, in your second page you could write that value in a hidden field by writing: <input type="hidden" name="nameoftour" value="<?=$_POST['nameoftour'];?>"/>
Last edited by 3Nex; 02-06-2011 at 09:12 AM.
i love easter eggs
(if you got any creative easter eggs, send me a PM)
How the hell did you get to read that, i edited that out later (you got it on your email i suppose)
Originally Posted by Optimistic
For the moment everything is in html except the php form for sending to email.
So it means I have to change my html form to a php one ?
I don't get what do you mean to do with your form if you're not gonna use some server-side programming? I mean, if you already are using forms to do anything, you obviously do own either a PHP or ASP server (PHP, according to your previous post) so the solution i proposed should work just fine in your case.
Unless i got your question wrong because i'm too lazy to read into your whole process of growing up as a child and getting to one day writing an html form that doesn't work. But as far as i can see, you already got the url in the field of your form and you want to put it in another field on the next form. Therefore, reading it with PHP is in fact the only solution.
i love easter eggs
(if you got any creative easter eggs, send me a PM)
Unless i got your question wrong because i'm too lazy to read into your whole process of growing up as a child and getting to one day writing an html form that doesn't work
It makes most sense to go ahead and make the form into a server-side page. Then you can check for any passed variables (I'd recommend GET rather than POST so the links will work even if not posted to from a previous form).
<?php and ?> brackets are used for writing PHP code in between. <?php echo $variable;?> is a PHP code for writing a variable called "variable".
The same thing is done by writing <?=$variable;?>, so use whichever suits you more.
$_POST is an array of variables that are submitted in a form from the page before (assuming that the form has method="post")
So, if you had an input field whose name was name="nameoftour", the value that user entered in that field will be accesible in $_POST['nameoftour'].
Finally, you will write that value out by using <?php echo $_POST['nameoftour'];?> or <?=$_POST['nameoftour'];?>. Naturally, if you wanted (which i suppose you did) to make that into a hidden field again, you will write <input type="hidden" name="name" value="<?=$_POST['nameoftour'];?>"/>
There is one caveat when using the shorthand version:
PHP Code:
<?=$variable;?>
This shorthand is disabled by default on PHP installs and thus may or may not be enabled on any particular host. It is considered best practice to use the full statement:
PHP Code:
<?php echo $variable;?>
This is often the cause of "when I moved to a new host my site stopped working..." posts on here.
switch($contactType){
case 'version2':
//Stuff for 'version2' goes here
break;
case 'version3':
//stuff for 'version3' goes here
break;
case 'version1':
default:
//This where you do stuff specific to "version1" which is also the default
break;
}
Bookmarks