Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 117,570 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,768 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Problen in inserting data Into table

 
Closed TopicStart new topic

Problen in inserting data Into table

msvp4u
post 16 Jul, 2008 - 01:12 PM
Post #1


New D.I.C Head

*
Joined: 15 Jul, 2008
Posts: 37


My Contributions


[query]
The problem which i face is because of the add button .Suggest me the ways to rectify it
[/query]

this is the form part of it
CODE

<html>
<body bgcolor=floralwhite leftmargin="0" topmargin="0" marginwidth="00" marginheight="0"  class=NormalFont>

<form method="post" action= "adduserprocess.php" >
<LABEL>First Name</LABEL>
<input type="text" name="txtFname" maxlength="50" class="MandatoryTextBox">
<LABEL>Last Name</LABEL>
<input type="text" name="txtLname" maxlength="50" class="MandatoryTextBox">
<input type="submit" class="NormalButton" value="Add" id=button6 name=button6 onclick="doSubmit()">
<input type=Reset class=NormalButton value="Cancel" id=button6 name=button6 onclick=java script:location.href="./userlist.php">
</body>
<script language="javascript">



function doSubmit(frm)

{

    if (frm.txtFname.value == "")  

    {

        alert("Enter First Name");

        frm.txtFname.focus();

    }

    else if(frm.txtLname.value == "")

    {

        alert("Enter Last Name");

        frm.txtFname.focus();

    }

    else

    {

        frm.action = "./adduserprocess.php";

        frm.submit();    

    }

}

</script>

</html>



php part
CODE

<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$userpassword=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="adduser"; // Table name

if (!isset($_POST['button6'])) {
} else {
$fname = $_POST['txtFname'];
$lname = $_POST['txtLname'];
mysql_query("INSERT INTO '$tbl_name' VALUES ('null','$fname','$lname')");
echo "Success! The $fname $lname has been added!";
}
?>

<script language="javascript">

    alert("<?php echo "$fname $lname"?> Successfully Added");

    location.href ("./userlist.php");

</script>




User is offlineProfile CardPM

Go to the top of the page


MitkOK
post 16 Jul, 2008 - 02:12 PM
Post #2


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 289



Thanked 9 times

Dream Kudos: 250
My Contributions


How do you expect from us to help you when you don't say what is your problem, what happens when you run this script, do you have any errors printed.
User is offlineProfile CardPM

Go to the top of the page

msvp4u
post 16 Jul, 2008 - 02:18 PM
Post #3


New D.I.C Head

*
Joined: 15 Jul, 2008
Posts: 37


My Contributions


there is no error displayed but when i press the add button it says successful but when i check the database it is being updated


sorry typing error

the database is not being updated



User is offlineProfile CardPM

Go to the top of the page

Closed TopicStart new topic
Time is now: 10/7/08 08:22PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month