hello to everYone!!
i m using following code for inserting the the data in my sql there is no syntax error no exception but the data is not inserting in the database
i also tried by $_POST instead of $_REQUEST but no result !
Hope any one would replyPHP Code:<?
ini_set("display_errors", 0);
if (isset($_REQUEST['submit'])) {
$name =$_REQUEST["username"];
echo $name;
$dbh=mysql_connect ('localhost','root','mypass');
mysql_select_db ("newdatabase");
mysql_query("insert into newtable (name) values($name)")
or die(mysql_error());
echo "Data Inserted!";
}
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
<table>
<tr>
<td>Please enter your name:</td>
<td> <input type="text" name="username" /></td>
</tr>
<td>Please enter your name1:</td>
<td> <input type="text" name="username1" /></td>
</tr>
<tr><td><input type="submit" value="submit" /></td></tr>
</table>
</form>
<?
}
else {
echo "Hello, " .$_REQUEST['username'];
}
?>




Reply With Quote