PHP注册表 [英] Registration Form in PHP

查看:120
本文介绍了PHP注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有两个php文件,第一个是reg.php,它有连接字符串和插入查询到数据库和其他php文件注册.php,它有一个文本框作为名字和注册CSS按钮。一旦按下注册按钮,错误发生为Undefined index:firstname,请告诉我如何将signup.php firstname文本框数据发送到reg.php?



您的最快的回复非常感谢。



 reg.php 
//连接字符串工作正常
$连接= mysql_connect($ host,$ dbuser,$ dbpass);
$ db = mysql_select_db($ dbname,$ connection);
$ firstName_txt = $ _GET ['firstname'];
$ sql =INSERT INTO Test(Rock)VALUES($ firstName_txt);
$ result = mysql_query($ sql);
echo谢谢;


signup.php
< 表格 名称 = reg method = POST action = reg.php >
< 输入 type = text 名称 = 冷杉tname id = firstname2 style = font-family:'Myriad Pro'; font-size:16px / >
< div id = cssButton > < a href = reg.php = 按钮自定义 > 注册< / a > < / div > ;
< / form >







现在问题是键入的值不是去数据库,总是以1为值。



reg.php

//连接字符串工作正常

$ connection = mysql_connect($ host,$ dbuser,$ dbpass);

$ db = mysql_select_db($ dbname,$ connection);

$ firstName_txt = isset($ _ POST ['firstname']);

$ sql =INSERT INTO Test(Rock)VALUES($ firstName_txt);

$ result = mysql_query($ sql);

echo谢谢;



signup.php
< form name =regmethod =POSTaction =reg.php>

< input type =submitname =POSTvalue = 注册/>

< / form>

解决方案

connection = mysql_connect(


宿主

DBUSER,

Hi,

I have two php documents first one is reg.php, it has connection string and insert query to the database and in the other php document signup.php, it has one textbox as first name and signup CSS button. Once press the sign up button, error occurred as Undefined index: firstname, kindly advise me how to get signup.php firstname textbox data to the reg.php?

Your soonest response is highly appreciated.

reg.php
//connection string is working properly
$connection = mysql_connect($host,$dbuser,$dbpass);
$db = mysql_select_db($dbname, $connection);
$firstName_txt = $_GET['firstname'];
$sql = "INSERT INTO Test (Rock) VALUES ($firstName_txt)";
$result = mysql_query($sql);
echo "Thank you";


signup.php
<form name="reg" method="POST" action="reg.php">
<input type="text" name="firstname" id="firstname2" style="font-family:'Myriad Pro';font-size:16px"/>
<div id="cssButton"> <a href="reg.php" class="button custom">Sign Up</a></div>
</form>



[Edited Question]
Now the problem is typed value is not going to the database, always going 1 as a value.

reg.php
//connection string is working properly
$connection = mysql_connect($host,$dbuser,$dbpass);
$db = mysql_select_db($dbname, $connection);
$firstName_txt = isset($_POST['firstname']);
$sql = "INSERT INTO Test (Rock) VALUES ($firstName_txt)";
$result = mysql_query($sql);
echo "Thank you";

signup.php
<form name="reg" method="POST" action="reg.php">
<input type="submit" name="POST" value="Register"/>
</form>

解决方案

connection = mysql_connect(


host,


dbuser,


这篇关于PHP注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆