View Single Post
Old 09-14-2007, 04:55 PM   #3 (permalink)
Haris
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

Quote:
Originally Posted by Karl View Post
Could you be a bit more specific as to what isn't working? So for example, say I select a question and then select edit choices. Are you saying that it isn't showing the data for the choices? If so, then that will be cause you need to get that data from the database using the ID you've passed through $_POST['edit_choices'].

On another note, there are also a few variable assignments to $_POST variables that have not been validated. This is generally a bad idea, but for simplicity, you could just ignore the error using @. Here are the ones I noticed:

1 near the top:

$submit_delete = @$_POST['delete'];

and these 3 near the bottom:

$submit_new_question = @$_POST['submit_new_question'];
$new_question = @$_POST['new_question'];
$edit_ID = @$_POST['selected_edit_q'];
Hmm, what I want to do is that when someone selects the checkbox to either edit the question or edit the choices for the question. The admin is redirected to edit questions or the choices.

In the delete_edit_questions.php, there are forms for both of the cases.

Edit_choice case

PHP Code:
elseif(isset($_POST['edit_choice'])){
    
$edit_choice_qID $_POST['edit_choices'];
    echo 
"<form method=\"POST\" name=\"choices\">";
    echo 
"First Choice(Positive): <input type=\"text\" name=\"choice_1\"><br>";
    echo 
"Second Choice(Negative): <input type=\"text\" name=\"choice_2\"><br>";
    echo 
"Third Choice(Any): <input type=\"text\" name=\"choice_3\"><br>";
    echo 
"<input type=\"hidden\" value=\"".$edit_choice_qID."\" name=\"edit_choices_qID\">";
    echo 
"<input type=\"submit\" name=\"submit_new_choices\" value=\"Edit\">";
    echo 
"</form>";
    if(isset(
$_POST['submit_new_choices'])){
        echo 
$_POST['choice_1'];
    }

Edit question case:

PHP Code:
elseif(isset($_POST['edit'])) {
    
$submit_edit $_POST['edit'];
    
$edit_qID $_POST['selected_edit_question'];
    echo 
"<form method=\"POST\" name=\"questions\">";
    echo 
"Enter new question: <input type=\"text\" name=\"new_question\">";
    echo 
"<input type=\"hidden\" value=\"".$edit_qID."\" name=\"selected_edit_q\">";
    echo 
"<input type=\"submit\" name=\"submit_new_question\" value=\"Edit\">";
    echo 
"</form>";
    
$submit_new_question $_POST['submit_new_question'];
    
$new_question $_POST['new_question'];
    
$edit_ID $_POST['selected_edit_q'];
    if(isset(
$submit_new_question)){
        
mysql_query("UPDATE questions SET question='$new_question' WHERE id='$edit_ID'") or die(mysql_error());
        echo 
"Question successfully changed to ".$new_question;
    }

Well, after they've entered the desired values in the text field to either edit the choices or the question, the values update the database and returns echo but it's not working. After submitting the form, nothing displays.
Haris is offline  
Reply With Quote