RealDrift Posted November 1, 2007 Share Posted November 1, 2007 Hi, I need help with this form submission, i understand for submission is the easiest thing to do in php. But i just can't get this to work. Basically i have a form in which is a question. I have given users choice of 4 answers to this question in a dropdown menu. I just want the form to recognise what answer the user has chosen and put it into a table called support and the column 'category' in it. The code is below. Please can somebody help me here. <?php session_start(); include_once "includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; $spt = $_POST['spt']; $title=$_POST['title']; $spt = strip_tags($spt); $title = strip_tags($title); $cat=strip_tags($_POST['category']); if ($cat == "Bug/Exploits Report"){ $category="Bug/Exploits Report'"; }elseif ($cat == "Duplicate Accounts Report"){ $category="Duplicate Accounts Report"; }elseif($cat == "Scam Report"){ $category="Scam Report"; }elseif($cat == "Scripter/Exploiter Report"){ $category="Scripter/Exploiter Report"; }elseif($cat == "Credits Question"){ $category="Credits Question"; }elseif($cat == "Other Question"){ $category="Other Question"; if ($_POST['open']){ if ($spt == "" || $title == ""){ echo "Fill in all fields."; }elseif ($spt != "" || $title != ""){ mysql_query("INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','$username','0','0','$spt',now(),'$title','$category');") or die (mysql_error()); echo "Ticket has been submitted."; }}} ?> <html> <link rel="stylesheet" href="includes/in.css" type="text/css"> <style type="text/css"> <!-- .style5 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; } .style10 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; } .style11 {font-size: 10px} .style12 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } --> </style> <center> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="39%"> </td> <td width="52%"> </td> <td width="9%"> </td> </tr> <tr> <td><table width=100% align="center" cellpadding=2 cellspacing=0 rules=none class=thinline> <tr> <td height="17" align=center background=includes/grad.jpg><span class="style10"><font color=#FFFFFF>Ticket Information</font></span></td> </tr> <tr> <td><span class="style12"> Submit a Ticket to an Admin or a Mod, Bugs will be fixed as soon as we read the message and if it is very serious we will reward you. Money Bugs Only Not Typing Errors! </span> <p class="style12"> <font color=#CC0000>Warning</font>: Tickets may take up to 24 hours to be answered so please be patient. </td> </tr> </table> <br> <table width=100% height="38" border=1 align="center" cellpadding=2 cellspacing=0 bordercolor=black class=thinline> <tr> <td height="19" colspan=2 align=center background=includes/grad.jpg><span class="style5 style11 style12"><font color=#FFFFFF>Open tickets</font></span></td> </tr> <td align=center bgcolor="#494949" class=style12 style8> Name</td> <td align=center bgcolor="#494949" class=style12 style8> Tickets Closed </td> </tr> <tr> <? /// add ticket ppl here $users_sup = array( "1" => "WentWorth", "2" => "Mobsterkenny", "3" => "Trivium", ); $i = 1; while ($i < 4){ $upstats = mysql_query("SELECT amount FROM ticketinfo WHERE username='$users_sup[$i]'"); while($getandpost = mysql_fetch_row($upstats)){ $total = $getandpost[0]; } echo "<tr><td><a href='profile.php?viewuser=$users_sup[$i]'>$users_sup[$i]</a></td> <td>$total</td></tr>"; $i++; } ?> </table></td> <td><table width=90% border=1 align=center cellpadding=1 cellspacing=1 bordercolor=black class="thinline"> <tr class=title> <td height="15" colspan="2" background=includes/grad.jpg><div align="center"><strong>Create Help Ticket </strong></div></td> </tr> <tr class=title> <td width="49%" height="15"><div align="center"><span class="style10">Topic Title</span></div></td> <td width="51%"><div align="center"> <input name="title" type="text" class="submit" style=width: size="60%";> </div></td> </tr> <tr class=title> <td height="29"><div align="center"><strong>Category</strong></div></td> <td height="29"><form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label> </label> <div align="center"> <select name="category"> <option value="Bug/Exploits Report" selected>Bug/Exploits Report</option> <option value="Duplicate Accounts Report">Duplicate Accounts Report</option> <option value="Scam Report">Scam Report</option> <option value="Scripter/Exploiter Report">Scripter/Exploiter Report</option> <option value="Credits Question">Credits Question</option> <option value="Other Question">Other Question</option> </select> </div> </form></td> </tr> <tr class=text> <td height="15" colspan="2" bgcolor="#494949"><div align="center"><span class="style10">Message</span></div></td> </tr> <tr class=sub> <td height="185" colspan="2"><div align="center"> <textarea name="spt" style="width: 98%; height: 175px" class="submit"></textarea> </div></td> </tr> <tr class=title> <td colspan="2"><div align="center"> <input name="open" type="submit" class="submit" style="background-color: #990000; bottom; background-repeat: repeat; border: 1; color: #FFFFFF; cursor: pointer; height: 20px;border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000; border-bottom: 1px solid #000000; font-size: 7.5pt; font-weight: normal; font-colour:#FFFFFF; font-family: Verdana" value="Open Help Ticket"> <label></label> </div></td> </tr> </table></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> <br> </tr> </td> </tr> </table> <br> </form> <br> I appreaciate any help, put me out of my misery. thanks Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/ Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 You never stated what the problem was... Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382439 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 Sorry, the problem is it doesn't add a row in the table "support". when i click the submit button nothing happens. I think i might have incorrectly coded the drop down menu. Is the script coded fine? Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382441 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 What is the error? This line mysql_query("INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','$username','0','0','$spt',now(),'$title','$category');") or die (mysql_error()); Should be mysql_query("INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','$username','0','0','$spt',now(),'$title','$category')") or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382448 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 ok i changed that, but nothing happens when i click the submit button. also did i code the drop down menu right? Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382453 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 You don't need this entire chunk of code <?php if ($cat == "Bug/Exploits Report") { $category="Bug/Exploits Report'"; } else if ($cat == "Duplicate Accounts Report") { $category="Duplicate Accounts Report"; } else if ($cat == "Scam Report") { $category="Scam Report"; } else if ($cat == "Scripter/Exploiter Report") { $category="Scripter/Exploiter Report"; } else if ($cat == "Credits Question") { $category="Credits Question"; } else if ($cat == "Other Question") { $category="Other Question"; ?> This line $cat = strip_tags($_POST['category']); will store the value. Here, I cleaned up the code a bit...see what this gives you. <?php session_start(); ?> <html> <link rel="stylesheet" href="includes/in.css" type="text/css"> <style type="text/css"> <!-- .style5 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; } .style10 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; } .style11 { font-size: 10px} .style12 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } --> </style> <?php include_once "includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; if ($_POST['open']) { $spt = $_POST['spt']; $title = $_POST['title']; $spt = strip_tags($spt); $title = strip_tags($title); $cat = strip_tags($_POST['category']); if ($spt == "" || $title == "") { echo "Fill in all fields."; } else if ($spt != "" || $title != "") { $query = "INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','$username','0','0','$spt',now(),'$title','$category')"; $result = mysql_query($query)or die($query.'<br>'.mysql_error()); echo "Ticket has been submitted."; } } ?> <center> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="39%"> </td> <td width="52%"> </td> <td width="9%"> </td> </tr> <tr> <td><table width=100% align="center" cellpadding=2 cellspacing=0 rules=none class=thinline> <tr> <td height="17" align=center background=includes/grad.jpg><span class="style10"><font color=#FFFFFF>Ticket Information</font></span></td> </tr> <tr> <td><span class="style12"> Submit a Ticket to an Admin or a Mod, Bugs will be fixed as soon as we read the message and if it is very serious we will reward you. Money Bugs Only Not Typing Errors! </span> <p class="style12"> <font color=#CC0000>Warning</font>: Tickets may take up to 24 hours to be answered so please be patient. </td> </tr> </table> <br> <table width=100% height="38" border=1 align="center" cellpadding=2 cellspacing=0 bordercolor=black class=thinline> <tr> <td height="19" colspan=2 align=center background=includes/grad.jpg><span class="style5 style11 style12"><font color=#FFFFFF>Open tickets</font></span></td> </tr> <td align=center bgcolor="#494949" class=style12 style8> Name</td> <td align=center bgcolor="#494949" class=style12 style8> Tickets Closed </td> </tr> <tr> <?php /// add ticket ppl here $users_sup = array("1" => "WentWorth", "2" => "Mobsterkenny", "3" => "Trivium", ); $i = 1; while ($i < 4) { $upstats = mysql_query("SELECT amount FROM ticketinfo WHERE username='$users_sup[$i]'"); while ($getandpost = mysql_fetch_row($upstats)) { $total = $getandpost[0]; } echo "<tr><td><a href='profile.php?viewuser=$users_sup[$i]'>$users_sup[$i]</a></td> <td>$total</td></tr>"; $i++; } ?> </table></td> <td><table width=90% border=1 align=center cellpadding=1 cellspacing=1 bordercolor=black class="thinline"> <tr class=title> <td height="15" colspan="2" background=includes/grad.jpg><div align="center"><strong>Create Help Ticket </strong></div></td> </tr> <tr class=title> <td width="49%" height="15"><div align="center"><span class="style10">Topic Title</span></div></td> <td width="51%"><div align="center"> <input name="title" type="text" class="submit" style=width: size="60%"; > </div></td> </tr> <tr class=title> <td height="29"><div align="center"><strong>Category</strong></div></td> <td height="29"><form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label> </label> <div align="center"> <select name="category"> <option value="Bug/Exploits Report" selected>Bug/Exploits Report</option> <option value="Duplicate Accounts Report">Duplicate Accounts Report</option> <option value="Scam Report">Scam Report</option> <option value="Scripter/Exploiter Report">Scripter/Exploiter Report</option> <option value="Credits Question">Credits Question</option> <option value="Other Question">Other Question</option> </select> </div> </form></td> </tr> <tr class=text> <td height="15" colspan="2" bgcolor="#494949"><div align="center"><span class="style10">Message</span></div></td> </tr> <tr class=sub> <td height="185" colspan="2"><div align="center"> <textarea name="spt" style="width: 98%; height: 175px" class="submit"></textarea> </div></td> </tr> <tr class=title> <td colspan="2"><div align="center"> <input name="open" type="submit" class="submit" style="background-color: #990000; bottom; background-repeat: repeat; border: 1; color: #FFFFFF; cursor: pointer; height: 20px; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000; border-bottom: 1px solid #000000; font-size: 7.5pt; font-weight: normal; font-colour:#FFFFFF; font-family: Verdana" value="Open Help Ticket"> <label></label> </div></td> </tr> </table></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> <br> </tr> </td> </tr> </table> <br> </form> <br> Post any errors if there are any. Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382458 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 thanks for your help nothing happens even now when i click the submit button however i get no errors, only that the button won't do anything Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382461 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 Try <?php session_start(); ?> <html> <link rel="stylesheet" href="includes/in.css" type="text/css"> <style type="text/css"> <!-- .style5 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; } .style10 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; } .style11 { font-size: 10px} .style12 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } --> </style> <?php include_once "includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; if ($_POST['open']) { $spt = $_POST['spt']; $title = $_POST['title']; $spt = strip_tags($spt); $title = strip_tags($title); $cat = strip_tags($_POST['category']); if ($spt == "" || $title == "") { echo "Fill in all fields."; } else if ($spt != "" || $title != "") { $query = "INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','$username','0','0','$spt',now(),'$title','$category')"; $result = mysql_query($query)or die($query.'<br>'.mysql_error()); echo "Ticket has been submitted."; } } ?> <center> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="39%"> </td> <td width="52%"> </td> <td width="9%"> </td> </tr> <tr> <td><table width=100% align="center" cellpadding=2 cellspacing=0 rules=none class=thinline> <tr> <td height="17" align=center background=includes/grad.jpg><span class="style10"><font color=#FFFFFF>Ticket Information</font></span></td> </tr> <tr> <td><span class="style12"> Submit a Ticket to an Admin or a Mod, Bugs will be fixed as soon as we read the message and if it is very serious we will reward you. Money Bugs Only Not Typing Errors! </span> <p class="style12"> <font color=#CC0000>Warning</font>: Tickets may take up to 24 hours to be answered so please be patient. </td> </tr> </table> <br> <table width=100% height="38" border=1 align="center" cellpadding=2 cellspacing=0 bordercolor=black class=thinline> <tr> <td height="19" colspan=2 align=center background=includes/grad.jpg><span class="style5 style11 style12"><font color=#FFFFFF>Open tickets</font></span></td> </tr> <td align=center bgcolor="#494949" class=style12 style8> Name</td> <td align=center bgcolor="#494949" class=style12 style8> Tickets Closed </td> </tr> <tr> <?php /// add ticket ppl here $users_sup = array("1" => "WentWorth", "2" => "Mobsterkenny", "3" => "Trivium", ); $i = 1; while ($i < 4) { $upstats = mysql_query("SELECT amount FROM ticketinfo WHERE username='$users_sup[$i]'"); while ($getandpost = mysql_fetch_row($upstats)) { $total = $getandpost[0]; } echo "<tr><td><a href='profile.php?viewuser=$users_sup[$i]'>$users_sup[$i]</a></td> <td>$total</td></tr>"; $i++; } ?> </table></td> <td><table width=90% border=1 align=center cellpadding=1 cellspacing=1 bordercolor=black class="thinline"> <tr class=title> <td height="15" colspan="2" background=includes/grad.jpg><div align="center"><strong>Create Help Ticket </strong></div></td> </tr> <tr class=title> <td width="49%" height="15"><div align="center"><span class="style10">Topic Title</span></div></td> <td width="51%"><div align="center"> <input name="title" type="text" class="submit" style=width: size="60%"; > </div></td> </tr> <tr class=title> <td height="29"><div align="center"><strong>Category</strong></div></td> <td height="29"><form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label> </label> <div align="center"> <select name="category"> <option value="Bug/Exploits Report" selected>Bug/Exploits Report</option> <option value="Duplicate Accounts Report">Duplicate Accounts Report</option> <option value="Scam Report">Scam Report</option> <option value="Scripter/Exploiter Report">Scripter/Exploiter Report</option> <option value="Credits Question">Credits Question</option> <option value="Other Question">Other Question</option> </select> </div> </td> </tr> <tr class=text> <td height="15" colspan="2" bgcolor="#494949"><div align="center"><span class="style10">Message</span></div></td> </tr> <tr class=sub> <td height="185" colspan="2"><div align="center"> <textarea name="spt" style="width: 98%; height: 175px" class="submit"></textarea> </div></td> </tr> <tr class=title> <td colspan="2"><div align="center"> <input name="open" type="submit" class="submit" style="background-color: #990000; bottom; background-repeat: repeat; border: 1; color: #FFFFFF; cursor: pointer; height: 20px; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000; border-bottom: 1px solid #000000; font-size: 7.5pt; font-weight: normal; font-colour:#FFFFFF; font-family: Verdana" value="Open Help Ticket"> <label></label> </div></td> </tr> </table></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> <br> </tr> </td> </tr> </table> <br> </form> <br> Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382467 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 hmm, the button works but i get the error "Fill in all fields." even though i have filled in the title and message fields what could be wrong now? Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382469 Share on other sites More sharing options...
darkfreaks Posted November 1, 2007 Share Posted November 1, 2007 <?php if(empty($title)||empty($spt)) { // echo }else{ //do whatever }?> Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382472 Share on other sites More sharing options...
MadTechie Posted November 1, 2007 Share Posted November 1, 2007 well style is badly formatted <input name="title" type="text" class="submit" style=width: size="60%"; > to <input name="title" type="text" class="submit" style="width: size='60%';"> try echoing them Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382475 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 nope i applied both changes but still get the same error of filling in all fields Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382479 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 Change this <?php if ($_POST['open']) { $spt = $_POST['spt']; $title = $_POST['title']; $spt = strip_tags($spt); $title = strip_tags($title); $cat = strip_tags($_POST['category']); if ($spt == "" || $title == "") { echo "Fill in all fields."; } else { $query = "INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','$username','0','0','$spt',now(),'$title','$category')"; $result = mysql_query($query)or die($query.'<br>'.mysql_error()); echo "Ticket has been submitted."; } } ?> To <?php if ($_POST['open']) { $spt = strip_tags(trim($_POST['spt'])); $title = strip_tags(trim($_POST['title'])); $cat = strip_tags($_POST['category']); if (empty($spt) && empty($title)) { echo "Fill in all fields."; } else if ($spt != "" || $title != "") { $query = "INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','$username','0','0','$spt',now(),'$title','$category')"; $result = mysql_query($query)or die($query.'<br>'.mysql_error()); echo "Ticket has been submitted."; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382480 Share on other sites More sharing options...
MadTechie Posted November 1, 2007 Share Posted November 1, 2007 yes can shoot in the dark until the cows come home.. did you try echoing them ? Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382481 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 poco i applied ur changes and this time it echos that the ticket has been submitted! that still leaves the problem of inserting row in table Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382482 Share on other sites More sharing options...
kratsg Posted November 1, 2007 Share Posted November 1, 2007 I need to mention one thing, ANY data that gets inserted into the database needs to be sanitized properly. In current PHP versions (don't ask me specifics), we have a mysql_real_escape_string to do that for us. IE: $variable = mysql_real_escape_string($_GET['variable']); $vars = mysql_real_escape_string($_POST['vars']); This covers the basic sql injections, you can add trim(), strip_tags(), str_replace, anything on top of that as you like, as long as you do mysql_real_escape_string FIRST and before you insert data into the database. Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382490 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 how do i apply that to my code? Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382491 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 poco i applied ur changes and this time it echos that the ticket has been submitted! that still leaves the problem of inserting row in table Well, what is wrong with the insertion? Do you get an error? Make sure you uncomment the insert code, I accidentally posted it commented out, then I fixed it. Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382498 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 i uncommented the insert query the form submits a row into the table but the values for id,category and title are empty Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382504 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 Okay, do this and post what it gives you. <?php $query = "INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','$username','0','0','$spt',now(),'$title','$cat')"; $result = mysql_query($query)or die($query.'<br>'.mysql_error()); echo '<p>'.$query.'<p>'; ?> Your id field should be empty...thats what you set it to be in the query. And the category variable should be $cat, not $category. I'm not sure whats going on with the $title var though. Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382506 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 i get this echoed on a completely new page: INSERT INTO `support` (`id`, `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('','username','0','0','title',now(),'','') Duplicate entry '' for key 1 shouldn't it be genrating a new id? also looks like it still hasn't put in a value for id,category,title Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382508 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 Okay, just don't fill in your "id" field for the table. Do you have it set to auto-increment in the DB? Do this <?php $query = "INSERT INTO `support` ( `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('$username','0','0','$spt',now(),'$title','$cat')"; $result = mysql_query($query)or die($query.'<br>'.mysql_error()); echo '<p>'.$query.'<p>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382509 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 i did auto_increment and updated code now on the same page above the table i get the following echoed: INSERT INTO `support` ( `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('WentWorth','0','0','message testing',now(),'','Scam Report') its recognising the category now but not title Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382510 Share on other sites More sharing options...
pocobueno1388 Posted November 1, 2007 Share Posted November 1, 2007 Okay...this *should* work. <?php session_start(); ?> <html> <link rel="stylesheet" href="includes/in.css" type="text/css"> <style type="text/css"> <!-- .style5 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; } .style10 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; } .style11 { font-size: 10px} .style12 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } --> </style> <?php include_once "includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; if ($_POST['open']) { $spt = strip_tags(trim($_POST['spt'])); $title = strip_tags(trim($_POST['title_insert'])); $cat = strip_tags($_POST['category']); if (empty($spt) && empty($title)) { echo "Fill in all fields."; } else { $query = "INSERT INTO `support` ( `writer`,`reply`,`read`,`ticket`,`time`,`title`,`category`) VALUES ('$username','0','0','$spt',NOW(),'$title','$cat')"; $result = mysql_query($query)or die($query.'<br>'.mysql_error()); echo '<p>'.$query.'<p>'; } } ?> <center> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="39%"> </td> <td width="52%"> </td> <td width="9%"> </td> </tr> <tr> <td><table width=100% align="center" cellpadding=2 cellspacing=0 rules=none class=thinline> <tr> <td height="17" align=center background=includes/grad.jpg><span class="style10"><font color=#FFFFFF>Ticket Information</font></span></td> </tr> <tr> <td><span class="style12"> Submit a Ticket to an Admin or a Mod, Bugs will be fixed as soon as we read the message and if it is very serious we will reward you. Money Bugs Only Not Typing Errors! </span> <p class="style12"> <font color=#CC0000>Warning</font>: Tickets may take up to 24 hours to be answered so please be patient. </td> </tr> </table> <br> <table width=100% height="38" border=1 align="center" cellpadding=2 cellspacing=0 bordercolor=black class=thinline> <tr> <td height="19" colspan=2 align=center background=includes/grad.jpg><span class="style5 style11 style12"><font color=#FFFFFF>Open tickets</font></span></td> </tr> <td align=center bgcolor="#494949" class=style12 style8> Name</td> <td align=center bgcolor="#494949" class=style12 style8> Tickets Closed </td> </tr> <tr> <?php /// add ticket ppl here $users_sup = array("1" => "WentWorth", "2" => "Mobsterkenny", "3" => "Trivium", ); $i = 1; while ($i < 4) { $upstats = mysql_query("SELECT amount FROM ticketinfo WHERE username='$users_sup[$i]'"); while ($getandpost = mysql_fetch_row($upstats)) { $total = $getandpost[0]; } echo "<tr><td><a href='profile.php?viewuser=$users_sup[$i]'>$users_sup[$i]</a></td> <td>$total</td></tr>"; $i++; } ?> </table></td> <td><table width=90% border=1 align=center cellpadding=1 cellspacing=1 bordercolor=black class="thinline"> <tr class=title> <td height="15" colspan="2" background=includes/grad.jpg><div align="center"><strong>Create Help Ticket </strong></div></td> </tr> <tr class=title> <td width="49%" height="15"><div align="center"><span class="style10">Topic Title</span></div></td> <td width="51%"><div align="center"> <input name="title_insert" type="text" class="submit" style=width: size="60%"; > </div></td> </tr> <tr class=title> <td height="29"><div align="center"><strong>Category</strong></div></td> <td height="29"><form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label> </label> <div align="center"> <select name="category"> <option value="Bug/Exploits Report" selected>Bug/Exploits Report</option> <option value="Duplicate Accounts Report">Duplicate Accounts Report</option> <option value="Scam Report">Scam Report</option> <option value="Scripter/Exploiter Report">Scripter/Exploiter Report</option> <option value="Credits Question">Credits Question</option> <option value="Other Question">Other Question</option> </select> </div> </td> </tr> <tr class=text> <td height="15" colspan="2" bgcolor="#494949"><div align="center"><span class="style10">Message</span></div></td> </tr> <tr class=sub> <td height="185" colspan="2"><div align="center"> <textarea name="spt" style="width: 98%; height: 175px" class="submit"></textarea> </div></td> </tr> <tr class=title> <td colspan="2"><div align="center"> <input name="open" type="submit" class="submit" style="background-color: #990000; bottom; background-repeat: repeat; border: 1; color: #FFFFFF; cursor: pointer; height: 20px; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000; border-bottom: 1px solid #000000; font-size: 7.5pt; font-weight: normal; font-colour:#FFFFFF; font-family: Verdana" value="Open Help Ticket"> <label></label> </div></td> </tr> </table></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> <br> </tr> </td> </tr> </table> <br> </form> <br> Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382518 Share on other sites More sharing options...
RealDrift Posted November 1, 2007 Author Share Posted November 1, 2007 lol sorry to say but it still doesn't put in a title why is it doing this? do we have to be so precise in the coding? Quote Link to comment https://forums.phpfreaks.com/topic/75585-solved-phphtml-form-submission/#findComment-382521 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.