2015-08-12 11:32
浏览 53


I have finish my validation form and everything working fine, but I have problem on how to transfer the data from the form to another .php page which is the process page.

I`m currently refer from this site for form validation code http://www.w3schools.com/php/showphp.asp?filename=demo_form_validation_required


<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" id="form">

                    <input type="text" name = "nama">
                    <span class="error">* <?php echo $nameErr;?></span>
                    Male</p><input type="radio" name= "gender" value="Male" >

                    <input name= "gender" type="radio" value="Female">
                    <span class="error">* <?php echo $genderErr;?></span>

                  <td>Contact No</td>
                    <input type="text" name= "contact">
                    <span class="error">* <?php echo $contactErr;?></span>

                    <textarea name= "address"></textarea>
                    <span class="error">* <?php echo $addressErr;?></span>
                    <input type="text" name= "email"></input>
                    <span class="error">* <?php echo $emailErr;?></span>
                  <td>Account Name</td>
                    <input type="text" name= "account"></input>
                    <span class="error">* <?php echo $accountErr;?></span>
                    <input type="password" name= "password"></input>
                    <span class="error">* <?php echo $passwordErr;?></span>
                  <input type="button" value="Cancel"onClick="history.go(-1);return true;">
                  <input type="submit" value="Submit">




$link = mysqli_connect('localhost', 'root', '', 'sport');


$sql = "INSERT INTO sport(name, gender, contact, address, email, account, password, eventtype) VALUES ('$nama' , '$gender', '$contact' , '$address', '$email', '$account', '$password', '')"; 

$query=mysqli_query($link, $sql);

if (!$query)
    echo "Fail to register";


How do I pass the data after I validate the form to process.php and execute the sql query so I store the data into the database. Supposedly we just put the target page in , but the code required me to use <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douwen1549 2015-08-12 11:50

    As per the link you have provided that they have used a server side validation instead of doing the server side validation try to do a client side validation by using the JavaScript or jQuery.

    you can check the simplest way of doing the JavaScript validation here : http://www.w3schools.com/js/tryit.asp?filename=tryjs_validation_js

    or you can try this by using any jquery library for form validation:


    for demo : http://formvalidator.net/#reg-form

    解决 无用
    打赏 举报
  • 查看更多回答(1条)

相关推荐 更多相似问题