Jump to content


Photo

submit help


  • Please log in to reply
8 replies to this topic

#1 blankextacy

blankextacy
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 28 October 2006 - 03:17 AM

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

<?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.";
}
?>



#2 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 28 October 2006 - 03:20 AM

Forgot the "".. shoud look like this:
<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>
i may have messed up putting all the quotes in but you see where they're supposed to go now right?

#3 blankextacy

blankextacy
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 28 October 2006 - 03:29 AM

no , its not that its something in the mysql coding im guessing

#4 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 28 October 2006 - 03:39 AM

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:
<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>
;D

#5 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 28 October 2006 - 03:41 AM

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:
<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>
and have your process page like this:
<?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.";
}
?>
try this..


#6 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 28 October 2006 - 03:54 AM

and make the table width 500 instead.. that should fit all the words in  ;D

#7 blankextacy

blankextacy
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 28 October 2006 - 04:01 AM

damn still not working

#8 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 28 October 2006 - 05:44 AM

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

<?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
}

?>



#9 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 28 October 2006 - 06:14 AM

no , its not that its something in the mysql coding im guessing


Then stop guessing and start debugging! As Alpine has demonstrated, its not too difficult to test your queries for error using the or die(mysql_error()) 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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users