Add data to mysql table
Posted: Wed Aug 15, 2007 10:51 am
feyd | Please use
So, can I make it that this:
$tbl_name="forum_question";
Can be the value of "$sendto"?
Thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi. I need a small bit of help. Is there a way that when I make a new message and send it, that the textbox called "sendto" will be the table name?
Code:Code: Select all
<?php
$host="localhost";
$username="";
$password="";
$db_name="test";
$tbl_name="forum_question";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$topic=$_POST['topic'];
$message=$_POST['message'];
$sendto=$_POST['sendto'];
$sender=$_POST['myusername']
$datetime=date("d/m/y h:i:s");
$sql="INSERT INTO $tbl_name(topic, message, datetime)VALUES('$topic', '$message', '$datetime')";
$result=mysql_query($sql);
if($result){
echo "Successful<BR>";
echo "<a href=inbox.php>Return to Inbox</a>";
}
else {
echo "ERROR";
}
mysql_close();
?>$tbl_name="forum_question";
Can be the value of "$sendto"?
Thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]