Input field

SpaceshipSpaceship
Watch

wc4life24

Established Member
Impact
0
I want to put some type of input on my website where people can submit questions, reviews, and other things. I've seen some codes for it but i don't understand what it does. What does it do when they submit something? How do i get it? Thanks for your help!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
You'll need a form itself :

HTML:
<form method="whatever" action="whatever.php">
<input name='whatever' type='input'>
<input type='submit' name='Submit' value='Sign in'>
</form>

Then whatever.php which processes the form
 
0
•••
thanks for the reply but after i add that code, what do i do with it? I don't see what happens when somebody types something in and clicks on "submit". It would probably help if you could explain it to me like i was a 5 year old.
 
0
•••
sure no problem. here's the 911... er i mean 411.

the form (what miseria posted) is the script that should be in your html file. this is what the user sees when they view your website and it has the boxes where they can type in their info.

now in "whatever.php", you have to have the script that you want to execute using the information that was put into the form. and where it says method="whatever", use method="post".

for example, say you have a form that asks for their name. they type in their name and press submit. then whatever that is typed into the box is sent to the .php file to execute. now in this script, you can use the information. ill show you how to make the page say "Hello, (person name)". heres the code for the html page where they would type in their name.

HTML:
<form name="name" action="name.php" method="post">
<input type="text" name="name" value="Insert Name Here">
<br>
<input type="submit" value="Submit">
</form>

here is the script that wud be in "name.php".

PHP:
<?php
$name=$_POST['name']; //define the variable that was sent via the form
$write="Hello, ";
$write.=$name; //make a variable of what you want to say
echo($write); //display what you want written
?>

now theyll see a page saying "Hello, NAME"

you can also do a LOT more with forms, and once you learn MySQL, it becomes invaluable. hope i helped. if you have any more questions, just ask.

(If this helped, please add reputation)
 
0
•••
nasaboy007 said:
sure no problem. here's the 911... er i mean 411.

the form (what miseria posted) is the script that should be in your html file. this is what the user sees when they view your website and it has the boxes where they can type in their info.

now in "whatever.php", you have to have the script that you want to execute using the information that was put into the form. and where it says method="whatever", use method="post".

for example, say you have a form that asks for their name. they type in their name and press submit. then whatever that is typed into the box is sent to the .php file to execute. now in this script, you can use the information. ill show you how to make the page say "Hello, (person name)". heres the code for the html page where they would type in their name.

HTML:
<form name="name" action="name.php" method="post">
<input type="text" name="name" value="Insert Name Here">
<br>
<input type="submit" value="Submit">
</form>

here is the script that wud be in "name.php".

PHP:
<?php
$name=$_POST['name']; //define the variable that was sent via the form
$write="Hello, ";
$write.=$name; //make a variable of what you want to say
echo($write); //display what you want written
?>

now theyll see a page saying "Hello, NAME"

you can also do a LOT more with forms, and once you learn MySQL, it becomes invaluable. hope i helped. if you have any more questions, just ask.

(If this helped, please add reputation)
It's also a good idea to do:

PHP:
<?php 
if($_POST['submit']) //Check to see if they actually hit submit :D
{
$name=$_POST['name']; //define the variable that was sent via the form 
$write="Hello, "; 
$write.=$name; //make a variable of what you want to say 
echo($write); //display what you want written 
}
else
{//whoops, they reached this page without submitting the form
die("You are not supposed to see this page!");
}
?>
That way, no data is displayed etc unless the person has "Submitted" the form :)

-Eric
 
0
•••
I tried the code that was posted and it didnt really work...i dont think that my host supports php. Is there any way to do it without using php, perl ect? All i want to do is let people type in reviews of a product and send them to me somehow. Thanks for the help
 
0
•••
well if ur host doesnt support PHP, you can always make a file called test.php and put this in it:

PHP:
<? phpinfo(); ?>

itll tell u if php is supported or not. i dont think you can do that without a server side script. javascript MIGHT be able to do it, but i dont think so (dont know javascript). i suggest a better host ;)
 
0
•••
try cgi :)
 
0
•••
well if the host dont support php, chances r it dont support cgi or asp or anything else lol
 
0
•••
Yeah my expirence is that hosts who do not support PHP do not support CGI. :p

wc4life, Do as nasa was saying. That should tell you whether they support PHP or not.
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back