...

View Full Version : PHP form submit help



StealthRadio
12-08-2008, 08:13 PM
Hello ive just set up a radio and im trying to, make a request script.

What im trying to do it have a form which has like

Name:

Email:

Request:

Then you click submit and it writes the infomation to a txt file and also add the date and then have the option to either make a request or shoutout, so theres a scroll menu which says request and shoutout. If any one has the code or a tutorial.

Ill really thank you.

mlseim
12-08-2008, 09:02 PM
I hate to just give a Google answer, but there are so many ways to do this,
and more decisions you need to make (like captcha?), validation issues, etc.

http://www.google.com/search?hl=en&q=php+form+save+to+file&btnG=Google+Search&aq=f&oq=

Plus, not many of us have time to write scripts for people. If you write your own
and ask questions about it, you might get some good help.

owt200x
12-08-2008, 09:11 PM
if youd like i could make your request form using my contact form at http://www.owt200x.us/contactform I could also integrate it into your form if you already have the html page made for it.

If you want me to make it let me know what fields.

I dont charge, but i do ask for a donation to build a homeless shelter.

Thanks,
Barry

StealthRadio
12-08-2008, 11:39 PM
Ok well ive made one well got some parts off google.


<?php
mysql_connect("host","username","password");
//Change the above line
mysql_select_db("database");
//Change the above line
$reg = "yes";
$ip = $_SERVER['REMOTE_ADDR'];
?>
<html>
<head>
<title>Request a song</title>
</head>
<body>
<?php
echo "Your ip is: ".$ip."<br />";
if (isset($_POST['submit'])) {
if (empty($_POST['song'])) {
echo "Sorry, you haven't supplied the song title!<br />";
$reg = "no";
}
if (empty($_POST['artist'])) {
echo "Sorry, you haven't supplied the artists name!<br />";
$reg = "no";
}
if (empty($_POST['name'])) {
echo "Sorry, you haven't supplied your name<br />";
$reg = "no";
}

$sql = "SELECT COUNT(*) FROM request_song WHERE ip='{$ip}'";
$result = mysql_query($sql);
if (mysql_result($result, 0) > 0) {
echo "Sorry, your ip has already wished for one song, you can not wish for <br />another until the DJ's have seen your request!<br />";
$reg = "no";
}
if ($reg == "yes") {
$sql = "INSERT INTO request_song(song, artist, name, ip)
VALUES('{$_POST['song']}', '{$_POST['artist']}', '{$_POST['name']}', '{$ip}')";
mysql_query($sql);
}
}
?>
<form action="request.php" method="POST">
<table>

<?php
mysql_connect("host","username","password");
//Change the above line
mysql_select_db("database");
//Change the above line
?>
<html>
<head>
<title>Requested songs</title>
</head>
<body>
<table width="600" border="1">
<tr><td>ID</td><td>Song</td><td>Artist</td><td>Requested by</td><td>IP</td><td>Delete</td></tr>
<?php
if ($_GET['del']) {
$delete = $_GET['del'];
$delque = "DELETE FROM request_song WHERE id='{$delete}'";
mysql_query($delque);
}
$query = "SELECT * FROM request_song ORDER BY id ASC";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$song = $row['song'];
$artist = $row['artist'];
$name = $row['name'];
$ip = $row['ip'];
echo "<tr><td>".$id."</td><td>".$song."</td><td>".$artist."</td><td>".$name."</td><td>".$ip."</td><td><a href='?del=".$id."'>Delete</a></td></tr>";
}
?>
</table>
</body>
</html>
But if i wanted to add the option shoutout so they can choose either request or shout out wat would i add? Thanks

mlseim
12-08-2008, 11:59 PM
I'm sort of ignorant about the radio thing.

What is the difference between a "shout out" and a "request".

Is it just a different field in the database, or does one get emailed and the other not?
What is supposed to happen between the two?

StealthRadio
12-09-2008, 12:50 AM
Well what i mean is like. The request is set out to add song name artist and user name. into the database then showes it up on the table. but i need to add where a mean comes down and u can click shoutout/request and i need to add more tables into the database but im not very good with mysql and only basic on php.

owt200x
12-09-2008, 01:32 AM
ohhhh, you want a form that sends the data to a sql table. my form code only sends the form data to email.

if you want to use mine with custom fields, let me know.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum