0

大家好,我正在尝试让我的第一个模态进行注册页面,以便将用户信息发布到 mysql。我已经尝试了一段时间,但似乎找不到我的错误,将不胜感激! 模态

    <div id="myModalRegister" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
              <h3 id="myModalLabel">Register</h3>
            </div>
            <div class="modal-body">
                <form id="modal-form" class="form-horizontal" action="register.php" onSubmit="return validateFormReg();" name="formregister">
    <div class="control-group">
    <label class="control-label" for="inputEmail">Email</label>
    <div class="controls">
    <input type="text" id="inputEmail" name="email" placeholder="Email">
    </div>
    </div>
    <div class="control-group">
    <label class="control-label" for="inputPassword" >Password</label>
    <div class="controls">
    <input type="password" id="inputPassword" name="pwd" placeholder="Password">
    </div>
    </div>
     <div class="control-group">
    <label class="control-label" for="inputPassword" >Password</label>
    <div class="controls">
    <input type="password" id="inputPassword" name="pwd1" placeholder="Retype Password">
    </div>
    </div>
     <div class="control-group">
    <label class="control-label" for="inputPassword">School</label>
    <div class="controls">

    <?php 
    $query      = sprintf("SELECT * FROM university");
    $result     = @mysql_query($query); 
    $rowModel   = mysql_fetch_array($result);

?>
    <select name="university" id="university">
    <option value="">Select University</option>
    <?php do {  ?>
    <option value="<?php echo $rowModel['university_id']; ?>"><?php echo $rowModel['name']; ?></option>
    <?php  }while ($rowModel = mysql_fetch_array($result));  ?>
  </select>


    </div>
    </div>
    <div class="control-group">
    <div class="controls">
   <input type="checkbox"  id="checky" name="checkbox"> I agree to the <a href="Terms.php" target="_blank">Terms of Service</a> and the <a href="Privacy.php" target="_blank">Privacy Policy</a><br><br><p>
<input type="submit" id="modal-form-submit" name="submit" value="Submit" class="btn btn-success" onclick="if(!this.form.checkbox.checked){alert('You must agree to the terms first.');return false}"  />
    </div>
    </div>
    </form>

            </div>
            <div class="modal-footer">
              <button class="btn" data-dismiss="modal">Close</button>

            </div>
          </div>    

这里是 PHP 发布的一面

    <?php
    include_once('inc/db.php');
    $tbl_name="user"; // Table name 



    $email = $_POST['email'];
    $password = $_POST['pwd'];
    $uni = $_POST['university'];

    $password = md5($password);


    $email = stripslashes($email);
    $password = stripslashes($password);
    $uni = stripslashes($un

i);


$email = mysql_real_escape_string($email);
$password = mysql_real_escape_string($password);
$uni = mysql_real_escape_string($uni);



    $sql_insert = "INSERT INTO $tbl_name(email , password, university_id) VALUES('$email', '$university_id', '$password')"; 
    $result_insert = mysql_query($sql_insert) or die(mysql_error());

    ?>
        <html>
        <head>
        <?php echo $uni?>
        <?php echo $email?>
        SEND TO PAGE

        </head>
        </html>
4

2 回答 2

0

不要放入 head 标签,使用 body 标签

改变

 <html>
        <head>
        <?php echo $uni?>
        <?php echo $email?>
        SEND TO PAGE

        </head>
        </html>

<html>
        <body>
        <?php echo $uni; ?>
        <?php echo $email; ?>
        SEND TO PAGE

        </body>
        </html>
于 2013-05-05T02:25:45.293 回答
-1

嘿,对不起,我发现了我的问题。首先在我的模态中,我没有方法“post”,在 sql 中我让 pwd 去 uni id 和 uni id 去 pwd。现在一切正常!!!

于 2013-05-05T20:48:25.800 回答