View previous topic :: View next topic |
Author |
Message |
pacho -
Joined: 03 Aug 2003 Posts: 1
|
Posted: Thu Aug 14, 2003 1:32 am Post subject: sending a form |
|
|
Hi, im trying to learn PHP, but some tutorials i found won't work. I want to send a form and process the variables with a .PHP file. But i get the error "variable undefined" or something like that. This is the code, if anyone can tell me what im doing wrong i'll thank you.
Sorry my poor english.
Code:
FILE1.PHP
<html>
<body>
<form method="post" action="file2.php">
Socio :<input type="Text" name="nombre"><br>
<input type="Submit" name="enviar" value="Aceptar información">
</form>
</body>
</html>
--EOF--
FILE2.PHP
<?
echo $nombre;
?>
--EOF--
Pacho |
|
Back to top |
|
 |
os17fan -
Joined: 21 Mar 2003 Posts: 531 Location: USA
|
Posted: Thu Aug 14, 2003 1:39 am Post subject: |
|
|
For one thing you setup the form wrong , its supposed to look like
<form action="your_file.php" method="post">
and one more thing you forgot to put , the file can not be processed without the post varible in your PHP area , put
Code: | echo $_POST["nombre"]; |
Here is a sample PHP Post script:
Name this: test.html
Code: | <form action="test.php" method="post">
<input type="text" name="test">
<input type="submit" value="Submit">
</form> |
Name this test.php
Code: | <?php
echo $_POST["test"];
?>
|
View a live example of this PHP script
http://www.offspringvideos.com/live/
For the submit button you don't need to put name="" , if you need a contact webmaster script , i made one for you and for other users on the forum
http://www.offspringvideos.com/contact_webmaster.zip Instructions included _________________ This web server is the best ! |
|
Back to top |
|
 |
eric -
Joined: 14 Aug 2003 Posts: 8
|
Posted: Sat Aug 16, 2003 6:26 pm Post subject: register_globals |
|
|
Your code could actually worked if you had turned on something called register_globals in php.ini in <WINDOWS DIRECTORY>/system32/php.ini.
The variable in the receiver script would then have worked because the variable would be set. However, this feature, register_globals, got turned off since version 4.2.0 of PHP because a cracker could set variables this way in the URL: myphp.php?myVar=something in the variable. |
|
Back to top |
|
 |
os17fan -
Joined: 21 Mar 2003 Posts: 531 Location: USA
|
Posted: Sat Aug 16, 2003 7:04 pm Post subject: |
|
|
My Register Globals is turned on , are you saying that my script is wrong or the script that the author of this post is wrong , im a NewB at PHP :oops: _________________ This web server is the best ! |
|
Back to top |
|
 |
eric -
Joined: 14 Aug 2003 Posts: 8
|
Posted: Sat Aug 16, 2003 9:29 pm Post subject: not you |
|
|
I was talking about the authors script :wink: |
|
Back to top |
|
 |
|