c0py Posted April 9, 2007 Share Posted April 9, 2007 Hi guys I hope you all had a nice easter. The problem i have is I'm trying to make a shoutbox that i can use with myspace, the idea was to use a form that would send the data to a mysql db that i could stick onto an image or use a basic flash movie to show it on the page, but myspace dont allow for php so i was wondering if theres a way i can use a normal form post action to send to a page that would take the data and then forward it on to the database. eg i would add <form action="http://mysite.com/shout.php" method="post"> name:<input type="text" name="name"><br> message:<input type="text" name="message"><br> <input type="submit" name="submit" value="Submit"> to my profile and have shout.php send it on. I have found a few tuts but they all deal with the form and php on the same page so i'm not sure if just using something like $name = $_POST['name']; $message = $_POST['message']; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); mysql_query("INSERT INTO `shoutbox` (id, DATE, name, message) VALUES ('',NOW(),'$name',$message')"); will work? any help or pointers to a tut would be muchlie cool thanks -Craig Link to comment https://forums.phpfreaks.com/topic/46341-form-to-php-to-mysql-help/ Share on other sites More sharing options...
Guest Posted April 9, 2007 Share Posted April 9, 2007 Hey, You pretty much already did it: you simply post your form to a script on another (or your) site or something, and let that script enter in the data into the database on a db server (or wherever the db is). For example, if you've got your myspace at http://myspace.com/here/, ad your website at http://mysite.com/... write the script, upload it to mysite.com and set your form on your myspace page to post it to http://mysite.com/script.php, and have that script put that data into the db there. However, if you want the results of the shoutbox to appear on myspace (without the help of a serverside language), you may have to resort to something a little more complicated. Probably use ajax to mimic SSI, or SSI itself. But I wouldn't know if myspace even allows javascript, Ive never used myspace. Just a note: you may want to sanitize input ($name and $message) using htmlentities() or mysql_real_escape_string() Link to comment https://forums.phpfreaks.com/topic/46341-form-to-php-to-mysql-help/#findComment-225452 Share on other sites More sharing options...
c0py Posted April 9, 2007 Author Share Posted April 9, 2007 Thanks for the quick reply 8ball. I've just tried but it doesn't seem to be saving anything to the database =( at least i know i'm on the right track though. thanks again! EDIT: I found the problem had my table inside ' these ' *slaps self* Link to comment https://forums.phpfreaks.com/topic/46341-form-to-php-to-mysql-help/#findComment-225463 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.