生日报名表麻烦 [英] birthday registration form trouble

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

问题描述

你好我正在为我的网站注册一个表单 http://social.nssgaming.com/但我在注册表单上有错误。我不知道有什么问题。我不会3盒,你可以在日期,蛾和年。
register.php位于这里: http://paste2.org/a31FJE5L
你可以在索引文件中看到生日的一部分:

hello I'm trying to make a registration form for my website http://social.nssgaming.com/ but i got a error in the registration form. and i don't know what's wrong. i wont 3 boxes where you can se date, moth, and year. register.php is located here: http://paste2.org/a31FJE5L you can se the part of birthday in the index file here:

<?php include("php_includes/registration.php"); ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Social Nssgaming</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="http://social.nssgaming.com/style/index/index.css">
<link rel='stylesheet' href='http://social.nssgaming.com/style/header/global.css' />
<script>
function emptyElement(x){
_(x).innerHTML = "";
}
function checkusername(){
var u = _("username").value;
if(u != ""){
    _("username_check").innerHTML = '<strong style="color:#3CF;">Checking database...      </strong>';
    var ajax = ajaxObj("POST", "index.php");
    ajax.onreadystatechange = function() {
        if(ajaxReturn(ajax) == true) {
            _("username_check").innerHTML = ajax.responseText;
        }
    }
    ajax.send("usernamecheck="+u);
}
}
function signup(){
var fn = _("firstname").value;
var ln = _("lastname").value;
var u = _("username").value;
var e1 = _("email1").value;
var e2 = _("email2").value;
var p1 = _("pass").value;
var p2 = _("pass2").value;
var c = _("country").value;
var g = _("gender").value;
var l = _("location").value;
var day = _("day").value;
var month = _("month").value
var year = _("year").value;
var bd = $_POST['month'];
var message = _("message");
if(u == "" || e1 == "" || e2 == "" || p1 == "" || p2 == "" || c == "" || g == "" || l  == "" || fn == "" || ln == "" || bd == ""){
    message.innerHTML = "Fill out all of the form data";
} else if(e1 != e2){
    message.innerHTML = "The email fields do not match";
} else if(p1 != p2){
    message.innerHTML = "The password fields do not match";
} else {
    _("signupbtn").style.display = "none";
    message.innerHTML = 'Please wait ...';
    var ajax = ajaxObj("POST", "index.php");
    ajax.onreadystatechange = function() {
        if(ajaxReturn(ajax) == true) {
            if(ajax.responseText != "signup_success"){
                message.innerHTML = ajax.responseText;
                _("signupbtn").style.display = "block";
            } else {
                window.scrollTo(0,0);
                _("signupform").innerHTML = "OK "+u+", check your email inbox and junk mail box at <u>"+e+"</u> in a moment to complete the sign up process by activating your account. You will not be able to do anything on the site until you successfully activate your account.";
            }
        }
    }
    ajax.send("u="+u+"&e="+e1+"&p="+p1+"&c="+c+"&g="+g+"&l="+l+"&fn="+fn  +"&ln="+ln+"&fn="+fn+"&bd="+bd);
}
}
</script>
</head>
<div id="custom_alert_overlay"></div>
<div id="custom_alert_box" style="width: 350px; background: #F6F6F6;">
<div>
<div id="dialogboxhead"></div>
<div id="dialogboxbody" style="background: #F6F6F6;">
</div>
</div>
</div>
<body style="margin: 0px; padding: 0px; font-family: 'PT Sans'; font-size: 14px;     background: #f4f4f4;">
<?php include_once("navigation_offline.php"); ?>
<div class="frontpage_wrapper">
<div class="frontpage_center">
  <span id="message"></span>
  <div id="about">
    <?php include_once("template_about.php"); ?>
  </div>
  <form name="signupform" id="signupform" onsubmit="return false;">
    <h2>Sign Up Here!</h2>
    <div id="input_center">
    <input type="text" name="firstname" size="25" placeholder="First Name" onfocus="emptyElement('message')" id="firstname" autocomplete="off" maxlength="50"/><br />  <br />
    <input type="text" name="lastname" size="25" placeholder="Last Name" onfocus="emptyElement('message')" id="lastname" autocomplete="off" maxlength="50"/><br /> <br />
    <input type="text" name="username" size="25" placeholder="Username" onfocus="emptyElement('message')" id="username" autocomplete="off" onblur="checkusername()" onkeyup="restrict('username')" maxlength="25"/>
    <span id="username_check"></span><br /><br />
    <input type="email" name="email" size="25" placeholder="Email" onfocus="emptyElement('message')" id="email1" autocomplete="off" maxlength="88"/><br /><br />
    <input type="email" name="confirm_email" size="25" placeholder="Confirm email" onfocus="emptyElement('message')" id="email2" autocomplete="off" maxlength="88"/><br /><br />
    <input type="password" name="password" size="25" placeholder="Password" onfocus="emptyElement('message')" autocomplete="off" maxlength="100" id="pass"/><br /><br />
    <input type="password" name="confirm_password" size="25" placeholder="Confirm password" onfocus="emptyElement('message')" autocomplete="off" maxlength="100" id="pass2"/><br /><br />
    <input type="text" name="location" size="25" placeholder="Location" onfocus="emptyElement('message')" id="location" autocomplete="off" maxlength="30"/><br />
    </div>
    <div id="birthday_container">
    <p class="subtitleparagraf_front">Birthday</p>
<?php

function GetMonthString($n){
$timestamp = mktime(0, 0, 0, $n, 1, 2010);
return date("F", $timestamp);
}

$display .= '</select>
<select name="year" class="birthday_btn" id="year">
<option value="">- Year -</option>';

$thisyear = date('Y');
$now = $thisyear - 1;
$end = $thisyear - 100 ;

for ($now; $now >= $end; $now--) {
if ($_POST['year'] == $now){
$display .= '<option value="'.$now.'" selected>'.$now.'</option>';
}
else{
$display .= '<option value="'.$now.'" >'.$now.'</option>';
}
}
$display .= '</select> ';

$display .='</select>
<select name="month" class="birthday_btn" id="month">
<option value="" >- Month -</option>';
for ($i = 1; $i <= 12; $i++) {
if ($_POST['month'] == $i){
$display .= '<option value="'.$i.'" selected>'.GetMonthString($i).'</option>';
}
else{
$display .= '<option value="'.$i.'" >'.GetMonthString($i).'</option>';
}
}


$display .= '</select>
<select name="day" class="birthday_btn" id="day">
<option value="'.$i.'" >- Day -</option>';

for ($i = 1; $i <= 31; $i++) {
if ($_POST['day'] == $i){
$display .= '<option value="'.$i.'" selected>'.$i.'</option>';
}
else{
$display .= '<option value="'.$i.'" >'.$i.'</option>';
}
}
$display .= '</select> ';

echo $display;
?>
    </div>
    <div id="sex_container">
      <input type="radio" name="gender" value="m" id="gender" checked  onfocus="emptyElement('message')">Male 
      <input type="radio" name="gender" value="f" id="gender" onfocus="emptyElement('message')">Female 
    </div>
    <div id="input_center">
    <select id="country" onfocus="emptyElement('message')" autocomplete="off">
      <?php include_once("template_country_list.php"); ?>
    </select><br /><br />
    <input type="button" id="signupbtn" onclick="signupEvent();" value="Create   Account!">
    </div>
    <div id="terms_container">By clicking "Create Account!" you agree with our terms of use!</div>
  </form>
</div>

我希望你能帮助我

推荐答案

我认为以下内容将有所帮助:

I think the following will help:

是你使用一个未定义的函数,而你实际上已经声明了你的函数,GetMonthString(),但你已经声明了你引用之后的函数,所以代码是自上而下的(至少对于变量),不会找到你的功能,最简单的解决方法是在调用它之前尝试定义函数,如下所示:

The error is that you use an "undefined function, while you actually have declared your function, GetMonthString(). But you've declared the function AFTER you refer to it. So the code, which is executed top-down(at least for the variables), will not find your function. The easiest solution is to try to define the function before calling it. Like this:

<?php

function GetMonthString($n){
$timestamp = mktime(0, 0, 0, $n, 1, 2010);
return date("F", $timestamp);
}

$display .= '</select>
<select name="year" class="birthday_btn" id="year">
<option value="">- Year -</option>';

$thisyear = date('Y');
$now = $thisyear - 1;
$end = $thisyear - 100 ;

for ($now; $now >= $end; $now--) {
if ($_POST['year'] == $now){
$display .= '<option value="'.$now.'" selected>'.$now.'</option>';
}
else{
$display .= '<option value="'.$now.'" >'.$now.'</option>';
}
}
    $display .= '</select> ';

    $display .='</select>
    <select name="month" class="birthday_btn" id="month">
    <option value="" >- Month -</option>';
    for ($i = 1; $i <= 12; $i++) {
    if ($_POST['month'] == $i){
    $display .= '<option value="'.$i.'" selected>'.GetMonthString($i).'</option>';
    }
    else{
    $display .= '<option value="'.$i.'" >'.GetMonthString($i).'</option>';
    }
    }


    $display .= '</select>
    <select name="day" class="birthday_btn" id="day">
    <option value="'.$i.'" >- Day -</option>';

    for ($i = 1; $i <= 31; $i++) {
    if ($_POST['day'] == $i){
    $display .= '<option value="'.$i.'" selected>'.$i.'</option>';
    }
    else{
    $display .= '<option value="'.$i.'" >'.$i.'</option>';
    }
    }
    $display .= '</select> ';

    echo $display;
    ?>

(对于额外的标签,对于中间的代码;)

(Sorry for the extra tab, halfway the code ;).

希望这将有助于您!

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

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