savagenoob Posted March 26, 2009 Share Posted March 26, 2009 I am submitting the test name via post and the test names have spaces in them, during the submit, the post does not recognize anything after a space and its driving me crazy. Such as Quiz 5, only comes through as Quiz. Here is some code.... $qname = $_POST['qname']; // This is the problem... if (isset($_POST['newquiz']) && ($myname != $qname)) { $select = mysql_query("INSERT INTO pq_quizname SET Name = '$qname'"); echo mysql_error(); echo "Added successfully"; echo "<meta http-equiv=Refresh content=3;url=quizadd.php>"; } else { ?> <table> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="newquiz"> <tr><th>New Quiz</th></tr> <tr><th>Quiz Name</th><td><input name="qname" type="text" size="20" maxlength="40" /></td></tr> <tr><td><input type="submit" name="newquiz" value="Next"></td></tr> </form> </table> <?php } ?> <?php require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $query = mysql_query("SELECT * FROM pq_quizname"); while($row = mysql_fetch_assoc($query)) { $showtest[] = $row['Name']; } ?> <table> <form action="takequiz.php" method="post" name="taketest"> <tr><th>Take a test</th></tr> <tr><td>Test </td><td><?php echo '<SELECT name=testname>'; foreach ($showtest as $key => $value) { echo '<OPTION value=' . $value . '> ' . $value . ''; } echo '</select>'; ?></td><td>Number of questions</td><td><input name="numques" type="text" size="3" maxlength="4" /></td></tr> <tr><td><input type="submit" name="takequiz" value="Take Test"></td></tr> </form> </table> Link to comment https://forums.phpfreaks.com/topic/151193-solved-_post-problem/ Share on other sites More sharing options...
chronister Posted March 26, 2009 Share Posted March 26, 2009 I am not 100% sure this will take care of it.... but I would start with valid HTML ....... echo '<SELECT name="testname">'; foreach ($showtest as $key => $value) { echo '<OPTION value="' . $value . '"> ' . $value . ''; } echo '</select>'; ?>< ........... I believe that attribute values in HTML are supposed to have quotes around them. I don't think it matters whether it is single or double quotes.... just put quotes around and I believe that it will fix it. Nate Link to comment https://forums.phpfreaks.com/topic/151193-solved-_post-problem/#findComment-794240 Share on other sites More sharing options...
savagenoob Posted March 26, 2009 Author Share Posted March 26, 2009 Yeah that doesnt help, you just put double quotes around single quotes and it would just make nothing come through, this is coming through but leaving the second part off, like "Quiz 7" is coming through as " Quiz " .This is so freakin wierd... Link to comment https://forums.phpfreaks.com/topic/151193-solved-_post-problem/#findComment-794755 Share on other sites More sharing options...
kenrbnsn Posted March 26, 2009 Share Posted March 26, 2009 Look at the generated source and post it here. The above suggestion should have worked. Please post your modified code. Ken Link to comment https://forums.phpfreaks.com/topic/151193-solved-_post-problem/#findComment-794757 Share on other sites More sharing options...
savagenoob Posted March 26, 2009 Author Share Posted March 26, 2009 You guys were right, I feel like a "special person". Thanks a million... this was frusterating me Link to comment https://forums.phpfreaks.com/topic/151193-solved-_post-problem/#findComment-794776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.