SunQuest
           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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 26th, 2002, 05:27 AM
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
it says undefined index name

hi pple! i need some help!

hmmm.. the prob is that i cannot store the user's input into the database. you see.. my first page is a form.html page. after the user key in their input and click on submit, it will display a display.php page! this page will just display what the user's input. if the user clicks on confirm button, this information will then be send to the database!

it is working fine when i pass the values from the firstpage to the display.php, but then when i click on the confirm button, it gives me an error saying Undefined Index! nothing is store in the database.. can anyone tell me wats the problem? btw.. i am using php4..

thx..

Reply With Quote
  #2  
Old August 26th, 2002, 06:22 AM
siteworkspro.com siteworkspro.com is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Sydney, Australia
Posts: 92 siteworkspro.com User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to siteworkspro.com Send a message via AIM to siteworkspro.com
RE: it says undefined index name

Ok, your not sending the data to the 3rd page. what you need to do on the second page, is to create hidden fields, that store the data, then create a submit button, that passes on the data to the 3rd page

Reply With Quote
  #3  
Old August 26th, 2002, 06:50 AM
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: it says undefined index name

hmmmmm... there is no error msg but unable to store the user input ito database.
err.. let me show you the codes:

first page coding:
<html>
<head>
<title>First Page</title>
</head>
<body>
<h1>Enter all the Information</h1>

<form action="display.php" method="post">
<table border=0>
<tr>
<td>Name</td>
<td><input type="text" name="name"><br></td>
</tr>
<tr>
<td>Sex</td>
<td><input type="text" name="sex"><br></td>
</tr>
<tr>
<td>Age</td>
<td><input type="text" name="age"><br></td>
<tr>
</tr>
<tr>
<td colspan=2><input type="submit" value="Register"></td>
</tr>
</table>
</form>

</body>
</html>

second page coding:
<html>
<head>
<title>Results</title>
</head>
<body>
<h2>Check Your Information. Once Confirm, Click on the Send,
Else return back to Edit ur Info</h2>

<form action="put.php" method="post">


<?php

$name = $_POST['name'];
$sex = $_POST['sex'];
$age = $_POST['age'];

print ("<p>Name: </b>n");
print ("$name");
print ("<br>Sex: </b>n");
print ("$sex");
print ("<br>Age: </b>n");
print ("$age");

?>
<table border=0>
<tr>
<td></td>
<td><input type="hidden" name="name" value=<?php $name ?>><br></td>
</tr>
<tr>
<td></td>
<td><input type="hidden" name="sex" value=<?php $sex ?>><br></td>
</tr>
<tr>
<td></td>
<td><input type="hidden" name="age" value=<?php $age ?>><br></td>
<tr>
</tr>
<tr>
<td colspan=2><input type="submit" value="Register"></td>
</tr>
</table>

<p>


</body>
</html>

third page coding:
<html>
<head>
<title>Results</title>
</head>
<body>
<h1>Results</h1>

<?php

$link = @mysql_connect("localhost", "root", "");
if (!$link)
{
print("Error");
exit;
}

if (!@mysql_select_db("information"))
{
print("cannot find database");
exit;
}
$name = $_POST['name'];
$sex = $_POST['sex'];
$age = $_POST['age'];

mysql_query("INSERT INTO info (name,sex,age) VALUES('$name','$sex','$age')");
print("Information Sent");

?>
</body>
</html>

thx...

Reply With Quote
  #4  
Old August 27th, 2002, 03:47 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: it says undefined index name

why don't u try to echo name, age and sex variables in last script to see if they are submited right..

or even beter, do a var_dump($_POST);

and another thing. html code for hidden fields should look like this

<input type="text" name="age" value="17">

and your code produces code like:

<input type="text" name="age" value=17>

note that the "" are missing. now, this MAY work sometimes, but u shouldn't relay on that...

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > it says undefined index name


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 2 hosted by Hostway