Jump to content

submit help


blankextacy

Recommended Posts

could some one tell me why this code isnt working the codes site is www.revo-online.net/gdmovies/submit.php

[code]<?php include("config.php"); ?>

Submit a video here


<form method=post action=submit.php?action=submit>

Video name:<input type=text name=name><br>
Email:<input type=text name=email><br>
Username:<input type=text name=user><br>
Picture link:<input type=text name=pic>(Http://www.site.com/pic.jpg)<br>
Video link:<input type=text name=link>(Http://www.site.com/link.vid)<br>
Type:<input type=text name=type>(fight)<br>
<input type=submit value=Submit><br>

</form>

<?php
if ($action == submit) {
if (!$name || !$email || !$user || !$pic || !$link ) {
print "You must fill out all fields.";

exit;
}
$dupe1 = mysql_num_rows(mysql_query("select * from videos where link='$link'"));
if ($dupe1 > 0) {
print "Someone is using that link!";

exit;
}
$dupe2 = mysql_num_rows(mysql_query("select * from videos where name='$name'"));
if ($dupe2 > 0) {
print "That name is being used!";

exit;

}
mysql_query("insert into players (name, email, user, pic, link, type, submitted)

values('$name','$email','$user','$pic','$link','$type','date('m/d/Y') ')") or die("Could not Submit.");
print "You're video has been submitted.";
}
?>

[/code]
Link to comment
Share on other sites

Forgot the "".. shoud look like this:
[code]<form method="post" action="submit.php">

Video name:<input type="text" name="name"><br>
Email:<input type="text" name="email"><br>
Username:<input type="text" name="user"><br>
Picture link:<input type="text" name="pic">(Http://www.site.com/pic.jpg)<br>
Video link:<input type="text" name="link">(Http://www.site.com/link.vid)<br>
Type:<input type="text" name="type">(fight)<br>
<input type="submit" value="Submit"><br>

</form>
[/code]
i may have messed up putting all the quotes in but you see where they're supposed to go now right?
Link to comment
Share on other sites

oh sorry but i wouldnt know.. and are you planning on setting up that form into a table? cuz right now it looks all messy lol here put it like this:
[code]<form method="post" action="submit.php">
<table width="350">
<tr><td>Video name:</td>
<td><input type="text" name="name"></td></tr>
<tr><td>Email:</td>
<td><input type="text" name="email"></td></tr>
<tr><td>Username:</td>
<td><input type="text" name="user"></td></tr>
<tr><td>Picture link:</td>
<td><input type="text" name="pic">(Http://www.site.com/pic.jpg)</td></tr>
<tr><td>Video link:</td>
<td><input type="text" name="link">(Http://www.site.com/link.vid)</td></tr>
<tr><td>Type:</td>
<td><input type="text" name="type">(fight)</td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>[/code]
;D
Link to comment
Share on other sites

i think the problem might have something to do with how you put two actions in the form.. and then you called for the submit action in the php script.. what i would do is have the form and then have the action go to like process.php and make that page with the script

this could be your script with the form:
[code]
<form method="post" action="process.php">
<table width="350">
<tr><td>Video name:</td>
<td><input type="text" name="name"></td></tr>
<tr><td>Email:</td>
<td><input type="text" name="email"></td></tr>
<tr><td>Username:</td>
<td><input type="text" name="user"></td></tr>
<tr><td>Picture link:</td>
<td><input type="text" name="pic">(Http://www.site.com/pic.jpg)</td></tr>
<tr><td>Video link:</td>
<td><input type="text" name="link">(Http://www.site.com/link.vid)</td></tr>
<tr><td>Type:</td>
<td><input type="text" name="type">(fight)</td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
[/code]
and have your process page like this:
[code]
<?php include("config.php"); ?>
<?php
//Your going to need to change the form input into variables
$name = $_POST['name'];
$email = $_POST['email'];
$user = $_POST['user'];
$pic = $_POST['pic'];
$link = $_POST['link'];

if (!$name || !$email || !$user || !$pic || !$link ) {
print "You must fill out all fields.";

exit;
}
$dupe1 = mysql_num_rows(mysql_query("select * from videos where link='$link'"));
if ($dupe1 > 0) {
print "Someone is using that link!";

exit;
}
$dupe2 = mysql_num_rows(mysql_query("select * from videos where name='$name'"));
if ($dupe2 > 0) {
print "That name is being used!";

exit;

}
mysql_query("insert into players (name, email, user, pic, link, type, submitted)

values('$name','$email','$user','$pic','$link','$type','date('m/d/Y') ')") or die("Could not Submit.");
print "You're video has been submitted.";
}
?>
[/code]
try this..
Link to comment
Share on other sites

Try this, should give you an error msg on the querys if they fail:
[code]

<?php

include("config.php");

if(isset($_POST['submit']))
{
if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['user']) && !empty($_POST['pic']) && !empty($_POST['link']) && !empty($_POST['type']))
{
foreach($_POST as $name => $value)
{
  ${$name} = htmlspecialchars($value);
}
$time = date('m/d/Y');

$sql = mysql_query("select * from videos where link='$link'") or die(mysql_error());
if(mysql_num_rows($sql) == 0)
{
$sql2 = mysql_query("select * from videos where name='$name'") or die(mysql_error());
if(mysql_num_rows($sql2) == 0)
{
$insert = mysql_query("insert into players (name, email, user, pic, link, type, submitted) values('$name','$email','$user','$pic','$link','$type','$time')") or die(mysql_error());
if($insert)
{
print "<p>You're video has been submitted.</p>";
$done = true; // hide form
}
else
{
print "<p>An error occured during the insert statement</p>";
}
}
else
{
print "<p>That name is being used!</p>";
}
}
else
{
print "<p>Someone is using that link!</p>";
}
}
else
{
print "<p>You must fill out all fields.</p>";
}
}

if(!$done)
{
echo <<<_HTML

Submit a video here:

<form method="post" action="submit.php">
Video name:<input type="text" name="name" value="$name" />
<br />
Email:<input type="text" name="email" value="$email" />
<br />
Username:<input type="text" name="user" value="$user" />
<br />
Picture link:<input type="text" name="pic" value="$pic" />(Http://www.site.com/pic.jpg)
<br />
Video link:<input type="text" name="link" value="$link" />(Http://www.site.com/link.vid)
<br />
Type:<input type="text" name="type" value="type" />(fight)
<br />
<input type="submit" name="submit" value="Submit" />
<br />
</form>

_HTML
}

?>

[/code]
Link to comment
Share on other sites

[quote]no , its not that its something in the mysql coding im guessing[/quote]

Then stop guessing and start debugging! As Alpine has demonstrated, its not too difficult to test your queries for error using the [i]or die(mysql_error())[/i] method. Its also often handy to store your sql statements in a string and thern echo() them so you can see what the database will actually be sent.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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