Jump to content

form to php to mysql, help


c0py

Recommended Posts

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

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()

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.