Jump to content

Unable to Insert form data into the Database???


rainaajeet

Recommended Posts

I have created a page through this code :

<html>
<title>Project Management</title>
<body>
<h1>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <u>Create New Project</u> &nbsp&nbsp&nbsp&nbsp</h1>

<form name="Enter New Task" action="addentry1.php" method="post">
<table width="20%" border="1">

<tr>
<td width=45%><b><font face=arial size=2>Project Name</font></b></td>&nbsp&nbsp
<td><b><font face=arial size=2><input type="text" name= "proj_name" value=""  >
</font>
</table>

<br>



<table width="100%" border="1">


<td><font size="-1"><b><font face="Arial,Helvetica,sans-serif">List of Tasks</font></b></font></td>
<td><font size="-1"><b><font face="Arial,Helvetica,sans-serif">Assigned To</font></b></font></td>
<td><font size="-1"><b><font face="Arial,Helvetica,sans-serif">Start Date</font></b></font></td>
<td><font size="-1"><b><font face="Arial,Helvetica,sans-serif">End Date</font></b></font></td>
<td><font size="-1"><b><font face="Arial,Helvetica,sans-serif">% Completion</font></b></font></body><body></td>

</tr>
  <tr>
<td><input type="text" name="list_of_task"></td>


<td>
<select name="assigned_to">
<option>Select</option>
<option>Abhinesh Sethumadhavan</option>
<option>Prabhu Hosmani</option>
</select></td>
<td><input type="text" name="start_date"></td>
<td><input type="text" name="end_date"></td>

<td><input type="text" name="completion_percent"></td>
 </tr>

<input type="submit" name="submit">
</body>
</html>

 

I created a page where I can allow user to insert data into created database "peisd" and tablename "task"

 

<html>

<title> Welcome to Project Management Tool</title>

<body bgcolor=ORANGE>

<h1> Please Wait...The Database is being Updated</h1>





<?php



if($_POST['submit']== "submit")

{

//header("Content-Type: text/plain");

$proj_name = $_POST['proj_name'];

$list_of_task = $_POST['list_of_task'];

$assigned_to = $_POST['assigned_to'];

$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];

$completion_percent = $_POST['completion_percent'];

/* set's the variables for MySQL connection */



$server = "localhost:3306"; // this is the server address and port

$username = "root"; // change this to your username

$password = "mysql123"; // change this to your password



/* Connects to the MySQL server */



$link = @mysql_connect ($server, $username, $password)

or die (mysql_error());



/* Defines the Active Database for the Connection */



if (!@mysql_select_db("peisd", $link)) {

    echo "<p>There has been an error. This is the error message:</p>";

    echo "<p><strong>" . mysql_error() . "</strong></p>";

    echo "Please Contact Your Systems Administrator with the details";

}



/* Passes a Query to the Active Database */



$result = mysql_query("INSERT INTO task ( proj_name,list_of_task,assigned_to,start_date,end_date,completion_percent)

VALUES ('$proj_name','$list_of_task','$assigned_to','$start_date','$end_date','$completion_percent')", $link);

if (!$result) {   echo("<p>Error performing create query: " . mysql_error() . "</p>");

 exit();

}

mysql_close ($link);

?>



</body>

</html>

 

But its not updating my database.

Pls Help

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

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.