|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
PHP+MySql
So I made www-page witch ask name and are you male of female. Then information will send to testi.php
Problem is that those variables witch are in testi.php page $name and $sex will not go any information and then it put my MySql-database just 0. What is wrong in my code or is it just me <html> <head> <title>testing</title> </head> <body background="pics/gray_fabric.gif"> <FORM ACTION="cgi-bin/testi.php" METHOD=POST > Nimi <input type="text" name="name" size="50" MAXLENGTH="50"> <br> <p> Your sex is<br>female <input type="radio" name="sex" value="female"> male<input type="radio" name="sex" value="male"> <p> <HR> <p> <INPUT TYPE="submit" VALUE="Send" NAME="Send"> <INPUT TYPE="reset" VALUE="reset" NAME="reset"> </FORM> </body> </html> --------------- <html> <body> <?php $mysql_yhteys = mysql_connect("connect...", "username", "") or die("can't connect?"); mysql_select_db("database", $mysql_yhteys) or die("can't choose your database..."); $query = "INSERT INTO kysely (name,sex) values ('$name','$sex')"; if (!$kysely1 = mysql_query($query,$mysql_yhteys)) { print "saving failed".mysql_error(); } else { print "OK"; } //$mysql_query($query, $mysql_yhteys); mysql_close($mysql_yhteys) or die("bla bla bla.. something is wrong"); echo "Connection is closed"; ?> </body> </html> And sorry my bad english..hope someone understand my problem.. |
|
#2
|
|||
|
|||
|
RE: PHP+MySql
You should look into using $_POST or $HTTP_POST_VARS (depending on your PHP version). That will solve your problem.
|
|
#3
|
|||
|
|||
|
RE: PHP+MySql
If you have register_globals = off (the suggested setting)
then use $_POST[$variableName] (as 'post' is your action] to declare your variables and to get the information out of them. look up $_POST in the manual for more detailed info |
|
#4
|
|||
|
|||
|
RE: RE: PHP+MySql
Quote:
do you mean like this <FORM ACTION="cgi-bin/testi.php" METHOD="$_POST["name"]"> |
|
#5
|
|||
|
|||
|
RE: PHP+MySql
I think everytime meant to leave you form alone, but do something like this in your processing script:
$query = "INSERT INTO kysely (name,sex) values ('".$_POST['name']."','".$_POST['sex']."')"; and obviously any other occurences of the $name or $sex variables would need to be changed also.... |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > PHP+MySql |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|