user1125233
user1125233

Reputation: 13

form submit fails to do as I want it to

<?=form_open('register');?> 
            <table>
                <tr>
                    <td><label for="register_name">Username : </label></td>
                    <td><input type="text" name="register_name" readonly="true" value="<?=$_POST['username']?>"/></td>                    
                </tr>
                <tr>
                    <td><label for="register_email">Email:</label></td>
                    <td><input type="text" name="register_email" readonly="true" value="<?=$_POST['email']?>"/></td>                
                </tr>                
                <tr>
                    <td><label for="register_password">Password:</label></td>
                    <td><input type="password" name="register_password" readonly="true" value="<?=$_POST['password']?>"/></td>                
                </tr>               
                <tr>
                    <td></td>
                    <td><input type="submit" value="Register" onclick="return true;"/></td>
                </tr>
                <tr>
                    <td></td>
                    <td>                     
                        <input type="submit" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['email']?>'&email='<?=$_POST['email']?>');return true;"/></td>                    
                </tr>
            </table>
        <?=form_close()?>

I have got an error at the final "input type=submit" as it is odd to me that after I press the button, it proceed further action (register) instead of returning back to the index page. Is the URL I use incorrect ? (I would like to return back the main page with the information for GETs)

UPDATE

I have a registration form (the main index page) in which the user is to fill in with username and password along with his email address. After he presses submit, he will be directed to Confirm page in which there is also a button to direct him back to the main page. The confirm page only rewrites his filled information from the index page. If he wants to change any, he can press the EDIT button. Once he presses it, I would like the information such as username and email address to still be existing on the index page. This is a little tricky part for newbies like me. I would like to learn how you deal with this. The above code is what I have tried without any luck at all because it registers when I press any of the two buttons.

Upvotes: 0

Views: 110

Answers (1)

nivanka
nivanka

Reputation: 1372

i am not sure why you are using a submit button here if you don't want to submit the page.

i see two options, make the

<input type="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['email']?>'&email='<?=$_POST['email']?>');return true;"/>

or return false in on submit action

<input type="submit" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['email']?>'&email='<?=$_POST['email']?>');return false;"/>

Upvotes: 1

Related Questions