'Two buttons one form
<?=form_open('blog/register');?>
<table>
<tr>
<td><label for="register_name">Username : </label></td>
<td><input type="text" name="register_name" readonly="readonly" value="<?=$_POST['username']?>"/></td>
</tr>
<tr>
<td><label for="register_email">Email:</label></td>
<td><input type="text" name="register_email" readonly="readonly" value="<?=$_POST['email']?>"/></td>
</tr>
<tr>
<td><label for="register_password">Password:</label></td>
<td><input type="password" name="register_password" readonly="readonly" 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="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['username']?>'&email='<?=$_POST['email']?>');return true;"/>
</td>
</tr>
</table>
<?=form_close()?>
That is the form with two buttons as two choices, the Register button is to redirect the user to the registered screen whereas the second button will direct him to the logon screen. It doesn't work, could someone offer me a hint or any instructions please ?
I click the second button and nothing happens. The first button works fine
Solution 1:[1]
Try replacing
<input type="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['username']?>'&email='<?=$_POST['email']?>');return true;"/>
with
<input type="button" value="Edit" onclick="window.location.href = 'http://localhost/index.php?username=<?=$_POST['username']?>&email=<?=$_POST['email']?>';return true;"/>
I believe you have some quotes mixed up.
To clarify, I removed the single quotes around your php because I believe they aren't necessary and cut off your location string at a place you don't want.
The location string that your code produces is 'http://localhost/index.php?username='
, which is incorrect.
UPDATE
Changed replace()
to href
Solution 2:[2]
Replace the code
<input type="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username='<?=$_POST['username']?>'&email='<?=$_POST['email']?>');return true;"/>
with
<input type="button" value="Edit" onclick="window.location.replace('http://localhost/index.php?username=<?=$_POST['username']?>&email=<?=$_POST['email']?>');return true;"/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Poonam |