如何将函数返回到与HTML / PHP相关的Div AP? [英] How do I return a function into a Div AP relating to HTML/PHP ?

查看:73
本文介绍了如何将函数返回到与HTML / PHP相关的Div AP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello forum!,



我有一个与PHP有关的脚本问题。



我正在创建一个网站,需要一个连接到 MSSQL 数据库的注册脚本,到目前为止我已设法编写脚本并使其连接到数据库并获得成功,但问题是,当进入一个字段并提交该功能时,它将 Echo 一个命令并将其放在页面顶部的某个地方,这是不是我想去的地方。



是否有任何使用HTML / PHP而不是jquery的函数我可以将该命令返回到DIV AP并在提交时打印文本?





[HTML]这是论坛容器

Hello forum!,

I have an issue with a script to do with PHP.

I'm creating a website which requires a register script that connects to "MSSQL" database, So far I've managed to script and make it connect to the database and be successful but the issue is that when entering in a field and submits the function it will "Echo" a command and places it on to the page up top somewhere which is not where I want it to go.

Is there any function using HTML/PHP instead of jquery that I could return that command into a "DIV AP" and print text when submitted?


[HTML] This is the Forum Container

<div id="BlogRegPanelHolder">
<form action="<?php echo $PHP_SELF?>" method="post" id="RegisterForm">

<div id="UserForm"><input name="name" type="Text" style="width: 458px; height: 31px; background:transparent; color: silver; border: 0px" value="" size="70" /></div>

<div id="UserPassForm"><input name="password" type="Password" style="width: 458px; height: 31px; background:transparent; color: silver; border: 0px" value="" size="70" /></div>

<div id="UserConfirmPassForm"><input name="password2" type="password" style="width: 458px; height: 31px; background:transparent; color: silver; border: 0px" value="" size="70" /></div>

<div id="UserEmailForm"><input name="email" type="Text" style="width: 458px; height: 31px; background:transparent; color: silver; border: 0px" value="" size="70" /></div>

<div id="RegButtonHolder">

<input

	type="image"

	name="submit"

	src="../../Images/RegButton.png"

	/>
<div id="UserField">Showing!</div>
<div id="UserPassField"></div>
<div id="UserPass2Field"></div>
<div id="UserEmailField"></div>
<!--<a href="#" ><img src="../../Images/RegButton.png" width="293" height="67" id="RegButton" /></a></div>-->
</div>
</form>







[PHP]这是脚本接下来




[PHP] This is the script that follows

<?php

$myServer = "127.0.0.1,1433";
$myUser = "User";
$myPass = "Pass";
$myDB = "Databse";

$name = $_POST['name'];
$pass = $_POST['password'];
$pass2 = $_POST['password2'];
$email = $_POST['email'];

$str_len1 = strlen($name);
$str_len2 = strlen($pass);
$str_len3 = strlen($email);


$s = @mssql_connect( $myServer, $myUser, $myPass )
    or die( "Couldn't connect to SQL Server on $myServer" );

$d = @mssql_select_db($myDB, $s)
    or die( "Couldn't open database $myDB" );


if ($str_len1 <= 0){
echo "<center><font color=red size=2> Enter your login information </font></center>";
exit();}

if ($str_len2 <= 0){
echo "<center><font color=red size=2> Enter the password </font></center>";
exit();}

if ($str_len1 < 4){
echo "<center><font color=red size=2> Login name is too short </font></center>";
exit();}

if ($str_len2 < 4){
echo "<center><font color=red size=2> Password is too short </font></center>";
exit();}

if ($pass != $pass2){
echo "<center><font color=red size=2> Enter a different password twice </font></center>";
exit();}

if ($str_len3 < 4){
echo "<center><font color=red size=2> email malformed </font></center>";
exit();}

if ($str_len1 > 12){
echo "<center><font color=red size=2> Login name is too long </font></center>";
exit();}

if ($str_len2 > 12){
echo "<center><font color=red size=2> Password is too long </font></center>";
exit();}

if (!preg_match("#^[a-z0-9]+$#i", $name)){
echo "<center><font color=red size=2> Login name must consist of letters or numbers </font></center>";
exit();}

if (!preg_match("#^[a-z0-9]+$#i", $pass)){
echo "<center><font color=red size=2> The password must be composed of letters or numbers </font></center>";
exit();}

$result = mssql_query( "[dbo].[DN_REGISTER] N'$name',N'$pass',N'$email'" );
mssql_close();

$row = mssql_fetch_array($result);
mssql_free_result($result);

if($row[0] == "2")
echo "<center><font color=red size=2> Account registration failed exist!</font></center>";
else if ($row[0] == "3")
echo "<center><font color=red size=2> Email use registration failed!</font></center>";
else
echo "<center><font color=green size=2> Congratulations, registration is successful!</font></center>";
?>





我也有一个环顾四周,除了我不想使用的jquery函数之外没有任何结果。如果任何人可以帮助我,我将非常感激!



I've also had a look around and got no result other than jquery functions which I don't want to use. If any one could help me out I would be much grateful!

推荐答案

PHP_SELF?> 方法 = post id = RegisterForm >

< div id = UserForm > < input name = 名称 type = 文本 style = width:458px;身高:31px;背景:透明;颜色:银色; border:0px value = size = 70 / > < / div >

< div id = UserPassForm > < 输入 名称 = 密码 类型 = 密码 样式 = 宽度:458像素;身高:31px;背景:透明;颜色:银色; border:0px value = size = 70 / > < / div >

< div id = UserConfirmPassForm > < 输入 name = password2 type = password 样式 = 宽度:458px;身高:31px;背景:透明;颜色:银色; border:0px value = size = 70 / > < / div >

< div id = UserEmailForm > < 输入 名称 =
email 类型 = 文字 样式 = 宽度:458像素;身高:31px;背景:透明;颜色:银色; border:0px value = size = 70 / > < / div >

< div id = RegButtonHolder >

< input

type = image

名称 = 提交

src = ../../ Images / RegButton.png

/ >
< div id = UserField > 显示!< / div >
< div id = UserPassField > < / div >
< div id = UserPass2Field > < / div >
< div id = UserEmailField > < / div >
<! - < a href =#>< img src = ../../Images/RegButton.pngwidth =293height =67id =RegButton/>< / a>< / div> - >
< / div >
< / form >
PHP_SELF?>" method="post" id="RegisterForm"> <div id="UserForm"><input name="name" type="Text" style="width: 458px; height: 31px; background:transparent; color: silver; border: 0px" value="" size="70" /></div> <div id="UserPassForm"><input name="password" type="Password" style="width: 458px; height: 31px; background:transparent; color: silver; border: 0px" value="" size="70" /></div> <div id="UserConfirmPassForm"><input name="password2" type="password" style="width: 458px; height: 31px; background:transparent; color: silver; border: 0px" value="" size="70" /></div> <div id="UserEmailForm"><input name="email" type="Text" style="width: 458px; height: 31px; background:transparent; color: silver; border: 0px" value="" size="70" /></div> <div id="RegButtonHolder"> <input type="image" name="submit" src="../../Images/RegButton.png" /> <div id="UserField">Showing!</div> <div id="UserPassField"></div> <div id="UserPass2Field"></div> <div id="UserEmailField"></div> <!--<a href="#" ><img src="../../Images/RegButton.png" width="293" height="67" id="RegButton" /></a></div>--> </div> </form>







[PHP]这是脚本接下来




[PHP] This is the script that follows

<?php


myServer = 127.0.0.1,1433\" ;
myServer = "127.0.0.1,1433";


myUser = 用户;
myUser = "User";


这篇关于如何将函数返回到与HTML / PHP相关的Div AP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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