Jump to content

Recommended Posts

<?php
mysql_connect("localhost","root" , "password") or die (mysql_error());

mysql_select_db("tutorial1") or die (mysql_error());


$personaldata = array("name" => $_POST['name'], "age" => $_POST['age'], "sex" => $_POST['sex']);

mysql_query("INSERT INTO personalinfo (name, age, sex) VALUES('$personaldata[name]', '$personaldata[age]', '$personaldata[sex]')") or die(mysql_error());

echo "You've submited this information. <br> name:" .$_POST['name']. "<br> Age:" .$_POST['age']. "<br> Sex: " .$_POST['sex'];

?>

 

for some reason only the Sex value is record, the rest is not, and does not even show up in the echo! maybe the varchar is not correct or something. Keep in my that the Sex value is a select menu where the others are text fields.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Personal Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p> </p>
<p>
</p>
<form name="form3" method="post" action="process.php">
  <p>Name: 
    <input type="name" name="textfield">
    <br>
    Age: 
    <input type="age" name="textfield22">
    <br>
    Sex: 
    <select name="sex">
      <option value="Male">Male</option>
      <option value="Female">Female</option>
    </select>
    <br>
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Submit2" value="Reset">
</form>
</body>
</html>

 

I don't get an error, it just does not show.

The problem is that the names of the fields that are not showing up are not "name" and "age" but "textfield" and "textfield22". Either change the PHP code to match the form or change the form to match the PHP code.

 

Ken

  <p>Name: 
    <input type="name" name="textfield">
    <br>
    Age: 
    <input type="age" name="textfield22">

<!-- Should be: -->

<input name="name" type="text" size=30>
<input name="age" type="text" size=3>

 

I changed the code, and this still has the same problem.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Personal Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p> </p>
<p>
</p>
<form name="form3" method="post" action="process.php">
  <p>Name: 
<input name="name" type="text" size=30>
    <br>
    Age: 
<input name="age" type="text" size=3>
    <br>
    Sex: 
    <select name="sex">
      <option value="Male">Male</option>
      <option value="Female">Female</option>
    </select>
    <br>
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Submit2" value="Reset">
</form>
</body>
</html>

 

<?php
mysql_connect("localhost","root" , "password") or die (mysql_error());

mysql_select_db("tutorial1") or die (mysql_error());


$personaldata = array("name" => $_POST['name'], "age" => $_POST['age'], "sex" => $_POST['sex']);

mysql_query("INSERT INTO personalinfo (name, age, sex) VALUES('$personaldata[name]', '$personaldata[age]', '$personaldata[sex]')") or die(mysql_error());

echo "You've submited this information. <br> name:" .$_POST['name']. "<br> Age:" .$_POST['age']. "<br> Sex: " .$_POST['sex'];

?>

 

the error was because of this quote

if i change the array to simpele $_POST[bLABLA] it has the same error

 

the reason for the

echo taith

 

was its quicker to say echo taith than

a) repeat what you said

b) quicker than typing

  • agree's with taith
  • yeah what taith said
  • did you even attempt what taith said

c) its shorter that typing print(taith);

 

LOL

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.