blankextacy Posted October 28, 2006 Share Posted October 28, 2006 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><?phpif ($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] Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 28, 2006 Share Posted October 28, 2006 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? Quote Link to comment Share on other sites More sharing options...
blankextacy Posted October 28, 2006 Author Share Posted October 28, 2006 no , its not that its something in the mysql coding im guessing Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 28, 2006 Share Posted October 28, 2006 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 Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 28, 2006 Share Posted October 28, 2006 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 scriptthis 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.. Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 28, 2006 Share Posted October 28, 2006 and make the table width 500 instead.. that should fit all the words in ;D Quote Link to comment Share on other sites More sharing options...
blankextacy Posted October 28, 2006 Author Share Posted October 28, 2006 damn still not working Quote Link to comment Share on other sites More sharing options...
alpine Posted October 28, 2006 Share Posted October 28, 2006 Try this, should give you an error msg on the querys if they fail:[code]<?phpinclude("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 <<<_HTMLSubmit 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] Quote Link to comment Share on other sites More sharing options...
trq Posted October 28, 2006 Share Posted October 28, 2006 [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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.