两个按钮一种形式

发布于 2025-01-05 19:23:35 字数 1872 浏览 0 评论 0原文

<?=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()?>

这是带有两个按钮作为两个选择的表单,“注册”按钮将用户重定向到注册屏幕,而第二个按钮将引导用户到登录屏幕。它不起作用,有人可以给我一个提示或任何指示吗?

我单击第二个按钮,但没有任何反应。第一个按钮工作正常

<?=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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

静谧幽蓝 2025-01-12 19:23:35

尝试替换

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

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

“我相信你混淆了一些引号”。

为了澄清这一点,我删除了 php 周围的单引号,因为我认为它们是不必要的,并在您不需要的地方切断了您的位置字符串。
您的代码生成的位置字符串是 'http://localhost/index.php?username=',这是不正确的。

更新
replace() 更改为 href

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

謌踐踏愛綪 2025-01-12 19:23:35

将代码替换

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

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

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;"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文