Jump to content

database not getting updated


kadamabhijeet_91

Recommended Posts

I have created a registration form.The data entered in the registration form must get updated in the database.after i enter the data im also getting no error.but if i check the database no data is visible in the database.im  attaching a file pls help me.

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/137669-database-not-getting-updated/
Share on other sites

Here is the coding  :)

 

Register.php page

<?php
include 'config.php';
include 'opendb.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="add_user.php">
  <p> </p>
  <table width="523" height="223" border="0">
    <tr>
      <td width="150"><div align="center"><strong>Name : </strong></div></td>
      <td width="357">
        <div align="left">
          <input type="text" name="name_textbox" id="name_textbox" />
        </div></td></tr>
    <tr>
      <td><div align="center"><strong>Age : </strong></div></td>
      <td>
        <div align="left">
          <input type="text" name="age_textbox" id="age_textbox" />
        </div></td></tr>
    <tr>
      <td><div align="center"><strong>Gender : </strong></div></td>
      <td><div align="left">
        <select name="list_gender" id="list_gender">
          <option>Male</option>
          <option>Female</option>
        </select>
      </div></td>
    </tr>
    <tr>
      <td><div align="center"><strong>Username : </strong></div></td>
      <td><div align="left">
        <input type="text" name="username_textbox" id="username_textbox" />
      </div></td>
    </tr>
    <tr>
      <td><div align="center"><strong>Password : </strong></div></td>
      <td><div align="left">
        <input type="password" name="password_textbox" id="password_textbox" />
      </div></td>
    </tr>
  </table>
  <p>
    <input type="submit" name="button" id="button" value="Submit" />
  </p>
  <p> </p>
</form>
</body>
</html>

 

add_user.php Page

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'demojoomla';
$dbname = 'user';

mysql_pconnect("localhost", "root", "demojoomla")or die("cannot connect server ");
mysql_select_db("user")or die("cannot select DB");


$ipaddress=$_SERVER['REMOTE_ADDR']; //IP Address

$sql="INSERT INTO user_tbl(name, age, gender, username, password, ipaddress)VALUES('name_textbox', 'age_textbox', 'list_gender, 'username_textbox', 'password_textbox', 'ipaddress)";
$result=mysql_query($sql);

//check if query successful
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='login.php'>View Login Page</a>"; // link to view guestbook page
}

else {
echo "ERROR";
}

mysql_close();
?>

 

What i have to do ???

Please help me .... ??? ???

um.... I think this will fix the issue, if you posted the actual code:

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'demojoomla';
$dbname = 'user';

mysql_pconnect("localhost", "root", "demojoomla")or die("cannot connect server ");
mysql_select_db("user")or die("cannot select DB");


$ipaddress=$_SERVER['REMOTE_ADDR']; //IP Address
$age = mysql_real_escape_string($_POST['age_textbox'];
$gender = mysql_real_escape_string($_POST['list_gender'];
$username = mysql_real_escape_string($_POST['username_textbox'];
$password = mysql_real_escape_string($_POST['password_textbox'];
$ip = mysql_real_escape_string($_POST['ipaddress'];
$sql="INSERT INTO `user_tbl`(`name`, `age`, `gender`, `username`, `password`, `ipaddress`)VALUES('name_textbox', '$age', '$gender, '$username', '$password', '$ip');";
$result=mysql_query($sql);

//check if query successful
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='login.php'>View Login Page</a>"; // link to view guestbook page
}

else {
echo "ERROR";
}

mysql_close();
?>

Thank You Johns Java

Its working fine

 

 

As you told that you are php programmer, do you know any THE BEST php & mysql Books ?

 

I want best of best. money is not an issue

I have a copy of "Beginning PHP 5 and MySQL: From Novice to Professional" on my shelf. I reference it more than any of my other 30 or so php books.  (ISBN 1-893115-51-8)  It has a good bit of information in it.  I highly recommend it to people new to PHP.  My version went for about $40USD, so it's not too bad on the wallet either.

Now i want to fetch out the data from database

Following is the code for result.php

 

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'demojoomla';
$dbname = 'user';

mysql_pconnect("localhost", "root", "demojoomla")or die("cannot connect server ");
mysql_select_db("user")or die("cannot select DB");

$sql="SELECT * FROM user";
$result=mysql_query($sql);

while($rows=mysql_fetch_array($result)){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table width="794" border="1">
  <tr>
    <td><div align="center">ID</div></td>
    <td><div align="center">NAME</div></td>
    <td><div align="center">AGE</div></td>
    <td><div align="center">GENDER</div></td>
    <td><div align="center">USERNAME</div></td>
    <td><div align="center">PASSWORD</div></td>
    <td><div align="center">IPADDRESS</div></td>
  </tr>
  <tr>
    <td><div align="center"><?php echo $rows['id'];?></div></td>
    <td><div align="center"><?php echo $rows['name'];?></div></td>
    <td><div align="center"><?php echo $rows['age'];?></div></td>
    <td><div align="center"><?php echo $rows['gender'];?></div></td>
    <td><div align="center"><?php echo $rows['username'];?></div></td>
    <td><div align="center"><?php echo $rows['password'];?></div></td>
    <td><div align="center"><?php echo $rows['ipaddress'];?></div></td>
  </tr>
</table>
</body>
</html>

 

I am using Dream weaver cs3 and phpDesigner 2008

Which software is FANTASTIC to use who shows design page and also coding page as this feature is there in Dreamweaver but in phpDesigner, i can have only coding side

 

Again, money is not issue,

Do you have skype account ? Please send me

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.