Need Help With a Form!
I am trying to create a form that captures basic information such as name, email address etc. Does anybody know of a way I can do this or a script that will allow me to direct the user to a page depending on the option they select?
The visitor has a drop down menu:
Choice 1
Choice 2
Choice 3
If they select Choice 2 they will be directed to microsoft.com. If they select Choice 3 they will be directed to msn.com.
Any suggestions would be greatly appreciated. I've tried looking through hotscripts.com and cgi-resources.com and a few others but I can't find something that will do this.
John Saunders
nike_guy_man posted this at 02:49 — 12th April 2002.
They have: 840 posts
Joined: Sep 2000
What language would you like it to be in?
In PHP, the formhandler would have this in it
<?php
if ($choice == \"choice1\") {
header(\"Location: <a href=\"http://www.yahoo.com/\" class=\"bb-url\">http://www.yahoo.com/</a>\");
} elseif ($choice == \"choice2\") {
header(\"Location: <a href=\"http://www.microsoft.com/\" class=\"bb-url\">http://www.microsoft.com/</a>\");
} elseif ($choice1 == \"choice3\") {
header(\"Location: <a href=\"http://www.msn.com/\" class=\"bb-url\">http://www.msn.com/</a>\");
} else {
print \"None of the above\";
}
?>
That SHOULD work... worked for me
[edit]
D'oh
Vbulletin parsed the links as URLs...
It should simply have the URLs no HTML tags... just
header("Location: url");
John Saunders posted this at 02:58 — 12th April 2002.
They have: 11 posts
Joined: Apr 2002
Hey Nike Guy Man,
Thanks for your reply. I can't believe something that seemed so hard could be done in that little amount of code. Should the third $choice variable have the 1 after it since the first two don't?
I have another question for you. I was using FormMail.cgi with my form which is written in Perl. Do you know of a form that I can use in PHP that will work with your script?
Also, is there anyway I can add a field that will allow the visitor to attach a small file in the form? Similar to the way vBulletin does this when replying to a post? Then the file would be sent in the e-mail along with the form results.
BTW..What part of Maryland are you from?
Thanks again for your help!
John Saunders
theprofessional posted this at 18:04 — 12th April 2002.
They have: 157 posts
Joined: Mar 2002
Assuming your form collected the persons email ($email) and that it somehow produces a password ($newpass) and has checked for unique username ($newid) then you'd send an email with your message ($message) using PHP like so: (if this was for a membership thing)
$message = "Welcome\n".
"Here is your new password -\n".
"User Name: $newid\n".
"Password: $newpass\n".
"If you have any problems, feel free to contact me at\n".
"[email protected].\n".
"-Webmaster\n".
"My Name";
mail($email,"Type the subject of your message here",$message,"From:My Name");
Go here to see about getting a file uploaded, 5th post down.
http://www.webmaster-forums.com/showthread.php?s=&threadid=18141&perpage=10&pagenumber=2
Never really used the email thing to send an attachment before. Any of you gurus know the part in mail to send an attachment?
theprofessional posted this at 18:07 — 12th April 2002.
They have: 157 posts
Joined: Mar 2002
And no, the third $choice variable wouldn't have a 1.
John Saunders posted this at 18:27 — 12th April 2002.
They have: 11 posts
Joined: Apr 2002
Clint,
Thanks for your response. I tried using your script in the post you referred me to, changed the path to the location of my images and CHMODED the directory to 777. Unfortunately, it isn't working. I'm not getting any error messages or anything and the image doesn't show up in the directory. I'm pretty sure that my host allows this as long as the permissions are set to 777.
Any ideas why it isn't working?
John Saunders
theprofessional posted this at 18:39 — 12th April 2002.
They have: 157 posts
Joined: Mar 2002
Did you try using copy(... instead of move_uploaded-file(...
And is your input field correct:
And the $pic variable must be set to something. You could use:
Look it over real good and try, try again. Seems that most of the time, my code fragments won't work because I forgot to include a ";" or a "(" or something small and stupid. Welcome to the world of bugs.
Mark Hensler posted this at 22:17 — 13th April 2002.
He has: 4,048 posts
Joined: Aug 2000
Encrypt goes in the tag, not the tag.
move_uploaded_file() requires PHP >= 4.0.3
copy() works on any version of PHP3 and PHP4.
move_uploaded_file() is prefered because it validates that the file in question is a file, and that it was uploaded via HTTP_POST. Copy will always work, but you'll have to add your own validation.
Unix directories should never be chmod 0777. If anything 0644. Apache only needs read access to server the pages, and write access to upload.
Mark Hensler
If there is no answer on Google, then there is no question.
John Saunders posted this at 01:39 — 14th April 2002.
They have: 11 posts
Joined: Apr 2002
I've tried using the script located in this post http://www.webmaster-forums.com/showthread.php?s=&threadid=18141&perpage=10&pagenumber=2 but I can't get it to work. My host is running PHP version 4.1.2 and I've been able to get the upload file thing to work with another script but I need it to work with just a simple form.
Could somebody make it so the script will work just as it's own file instead of having to be added to another script so I can test it by itself?
John Saunders
Mark Hensler posted this at 01:56 — 14th April 2002.
He has: 4,048 posts
Joined: Aug 2000
Whoops, I made a typo. Directories should be 0766, not 0644.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.