drugs3550 2016-05-24 03:25
浏览 34

为什么php代码在wordpress中执行3次

I am very new to wordpress. I am trying to do the following:

a. I have a very simple html and php based website. I have a signup page which accepts user id and password and then on click of submit button it calls a php file which verifies the userid/password and saves it in the database. THIS WORKS PERFECTLY FINE

b. Now, I trying to move those two pages to wordpress platform. I have installed a php plugin also. Now the problem in wordpress platform is whenever I hit the submit button, in the database 3 duplicate records are getting appended. I have been trying a lot but could not fix this

c. I tried different php plugins but does not work

d. After reading few help documents on the web, I have tried creating my own template page, even that does not work

Any help in this regard will be much appreciated.


EDIT

Form:

<form action="http://xxxxxx.xxx/xxxxxx" method="post">
    Enter User ID:
    <input name="userid" type="text" value="" />Password:
    <input name="password" type="text" value="" />
    Confirm Password:
    <input name="confrimpassword" type="text" value="" />
    <input type="submit" value="SIGN UP" />
</form>

Below is the php file:

<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
// Echo session variables that were set on previous page
//echo "Favorite color is ".$_SESSION["favcolor"].".<br>";
//echo "Favorite animal is ".$_SESSION["favanimal"].".";
?>
<?php
mysql_connect("localhost","***********","**************");
mysql_select_db("******");
$sql1=mysql_query("select * from login_details where customer_id='$_POST[userid]'");

$row=mysql_fetch_assoc($sql1);
if (!$sql1) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    //exit;
}
else {
    echo " inside last else";
    $sql2=mysql_query("INSERT INTO login_details VALUES ('$_POST[userid]','$_POST[password]')");
    echo "Account successfully Created...";
}
mysql_close();
?>
</body>
</HTML>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求帮我调试一下freefem代码
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图