I have a classifieds webbsite, and users have the option to change / remove their classifieds.
I am working on a "edit.php" page where all this can be done.
Basically it is setup like this when you click on "edit/remove classified":
A new page appears, with a form, where user may chose from "REMOVE" and "CHANGE" through radios. The user must enter a password which is connected to the classified. Then they hit submit.
The Form is submitted to itself, and checks which radio is selected, and checks if password was correct.
If the password is wrong, then the same page appears again, but with a message saying, "wrong password".
If the password is right, then based on if the user wants to "REMOVE" or "CHANGE" the classified, I want a completely new page to open.
My question is, would it be possible ans secure to open a new page based on the radio selection, via php?
Otherwise I would have to put so many if/else statements into the HTML and showing different forms with different actions, that it would be so messy.
So in PHP I would like to do this:
<?php
if($password==$row['pass']){
if($action == "remove"){ Open new page and DO remove }
else if ($action == "change"){ Open new page and change the classified }
}
?>
I use session for storing variables.
Is it possible, and secure to open a new page and just remove the classified for example? Or would it be safer to have multiple forms and display them based on the php form selections and password errors?
Hard to explain, but I want simply to avoid alot of if/else in my HTML. Otherwise it would be something like:
<body>
<?php if($pass_wrong==1): ?>
FORM COMES HERE, AND STATES PASSWORD WAS WRONG
<?php endif; ?>
<?php if($action=='remove' && $pass_wrong==0): ?>
CLASSIFIED SUCCESSFULLY REMOVED
<?php endif; ?>
<?php if($action=='change' && $pass_wrong==0): ?>
Show a huuuuuge form to change the classified
<?php endif; ?>
ETC ETC