Jump to content

need help


doforumda

Recommended Posts

here is the code

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>insertinto</title>

</head>

 

<body>

<?php

$db = mysql_connect("localhost","username","password");

mysql_select_db("nu",$db);

$query = "insert into student (name, fname, age, phone) values ('".$name."','".$fname"','".$age."','".$phone."')" or die(mysql_error());

$run = mysql_query($query) or die(mysql_error());

 

echo "Your data is entered correctly......";

?>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/153291-need-help/#findComment-805335
Share on other sites

 

bit better with database protection.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>insertinto</title>
</head>

<body>
<?php
$db = mysql_connect("localhost","username","password");
mysql_select_db("nu",$db);

$query="insert into student(name, fname, age, phone)values('".mysql_real_escape_string($_POST['name'])."','".mysql_real_escape_string($_POST['fname'])."','".mysql_real_escape_string($_POST['age'])."','".mysql_real_escape_string($_POST['phone'])."')";

$run = mysql_query($query) or die(mysql_error());

echo "Your data is entered correctly......";
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/153291-need-help/#findComment-805499
Share on other sites

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.