PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 7th, 2002, 01:11 PM
Jussi Jussi is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 Jussi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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..

Reply With Quote
  #2  
Old May 7th, 2002, 03:25 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: PHP+MySql

You should look into using $_POST or $HTTP_POST_VARS (depending on your PHP version). That will solve your problem.


Reply With Quote
  #3  
Old May 7th, 2002, 04:47 PM
everytime everytime is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: *.*
Posts: 133 everytime User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #4  
Old May 13th, 2002, 12:29 PM
Jussi Jussi is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 Jussi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: RE: PHP+MySql

Quote:
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


do you mean like this

<FORM ACTION="cgi-bin/testi.php" METHOD="$_POST["name"]">

Reply With Quote
  #5  
Old May 13th, 2002, 02:57 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
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....

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > PHP+MySql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway