dsjoes
20 Dec 2010, 05:34 PM
i have got a form that lets me send information to mysql database to be displayed on a table.
this is the form:
<form action="insert.php" method="post">
Name: <input type="text" name="Name" /><br />
Message: <input type="text" name="Message" /><br />
Download: <input name="Download" type="text" /> <br />
<input type="submit" value="Submit" /></form>
and this is the insert script:
<?php
$con = mysql_connect("host","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("b32_5584692_Docs", $con);
$sql="INSERT INTO Docs(Name, Message, Download)
VALUES
('$_POST[Name]','$_POST[Message]','$_POST[Download]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Record added";
header('Location: upload_test.php');
mysql_close($con)
?>
i am wanting to make it easier to make a link in the download section so that i am not having to type this in everytime i add a new link.
This
<a href="test.doc">Download</a>
in here
Download: <input name="Download" type="text" />
i have been given this code but i am not sure where i need to put it and if there is anything else i need to do with it:
// *** Read the value of "Download" (POST or GET method).
if (isset(($_POST['Download'])) $fileName = $_POST['Download'];
if (isset(($_GET['Download'])) $fileName = $_POST['Download'];
// *** Build the link string.
$downloadLink = "<a href=\"$fileName\">Download</a>";
thanks
this is the form:
<form action="insert.php" method="post">
Name: <input type="text" name="Name" /><br />
Message: <input type="text" name="Message" /><br />
Download: <input name="Download" type="text" /> <br />
<input type="submit" value="Submit" /></form>
and this is the insert script:
<?php
$con = mysql_connect("host","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("b32_5584692_Docs", $con);
$sql="INSERT INTO Docs(Name, Message, Download)
VALUES
('$_POST[Name]','$_POST[Message]','$_POST[Download]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Record added";
header('Location: upload_test.php');
mysql_close($con)
?>
i am wanting to make it easier to make a link in the download section so that i am not having to type this in everytime i add a new link.
This
<a href="test.doc">Download</a>
in here
Download: <input name="Download" type="text" />
i have been given this code but i am not sure where i need to put it and if there is anything else i need to do with it:
// *** Read the value of "Download" (POST or GET method).
if (isset(($_POST['Download'])) $fileName = $_POST['Download'];
if (isset(($_GET['Download'])) $fileName = $_POST['Download'];
// *** Build the link string.
$downloadLink = "<a href=\"$fileName\">Download</a>";
thanks