quelle Posted December 18, 2010 Share Posted December 18, 2010 Here's what i got, a part of poll script, actually this is for a user with some more priviliges... The problem I am facing is actually that my php code doesn't even recognize the text in HTML Form - the text boxes(at least thats what I think so). I made 2 errors - one if client didnt type the title of poll and one if there are lower than 2 answers. And the problem is Im getting those 2 problems all the time no mather what I type in textboxes <?php } function GetNewPollDetails(){ ?> <h1>Nova anketa</h1> <form name="frmAddPoll" action="managepoll.php?method=AddFinal" method="post"> <br /> Pitanje Ankete:<input type="text" name="$question" /> <br /> Odogovor 1:<input type="text" name="answer1" /> <br /> Odogovor 2:<input type="text" name="answer2" /> <br /> Odogovor 3:<input type="text" name="answer3" /> <br /> Odogovor 4:<input type="text" name="answer4" /> <br /> Odogovor 5:<input type="text" name="answer5" /> <br /> <input type="submit" value="Napravi" name="napravi" /> </form> <?php } function AddPoll(){ global $question; global $answer1; global $answer2; global $answer3; global $answer4; global $answer5; $numAnswers = 0; $err = ""; if($answer1 != "") { $numAnswers++; } if($answer2 != "") { $numAnswers++; } if($answer3 != "") { $numAnswers++; } if($answer4 != "") { $numAnswers++; } if($answer5 != "") { $numAnswers++; } if($question == "") $err .= "<li>You didn't enter a title</li>"; if($numAnswers < 2) $err .= "<li>You must enter at least two answer choices</li>"; if($err != "") { ?> <h1>Incomplete Fields</h1> You didn't complete all of the details for this poll. Take a look at the errors below and click the link below to go back and correct them: <ul> <?php echo $err; ?> </ul> <a href="javascript:history.go(-1)">Go Back</a> <?php return; } include("dbvars.php"); @$svrConn = mysql_connect($host, $user, $pw) or die("Couldn't connect to the database server"); @$dbConn = mysql_select_db("websitenforum", $svrConn) or die("Couldn't connect to the database"); $strQuery = "INSERT INTO pollQuestions VALUES("; $strQuery .= "0, '$question', '$answer1', '$answer2', '$answer3', '$answer4', '$answer5')"; if(mysql_query($strQuery)) { echo "You made it, yes!"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/222032-php-doesnt-recognize-text-in-html-form/ Share on other sites More sharing options...
QuickOldCar Posted December 18, 2010 Share Posted December 18, 2010 Since you have this line outside of php and just html, you must have the start and stop for php code. so this Pitanje Ankete:<input type="text" name="$question" /> to this Pitanje Ankete:<input type="text" name="<?php echo $question;?>" /> If you echoed the html code and needed the variable, no need to have the start and stops, but do need to have them wrapped in the correct quotes at times. Quote Link to comment https://forums.phpfreaks.com/topic/222032-php-doesnt-recognize-text-in-html-form/#findComment-1148876 Share on other sites More sharing options...
quelle Posted December 18, 2010 Author Share Posted December 18, 2010 well doing it on ur way I actually define nothing ... I tried it on this way $question = $_POST['question']; $answer1 = $_POST['answer1']; $answer2 = $_POST['answer2']; $answer3 = $_POST['answer3']; $answer4 = $_POST['answer4']; $answer5 = $_POST['answer5']; But my whole script fucked up after I changed what u said, dunno what's the problem gotta go sleep now ill try tommorow Quote Link to comment https://forums.phpfreaks.com/topic/222032-php-doesnt-recognize-text-in-html-form/#findComment-1148885 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.