jquery+ajax+php
in PHP with 3 comments

jquery+ajax+php

in PHP with 3 comments

index.html

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>league</title>
    <script src="http://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.2.min.js"></script>
</head>

<body>
    <form>
        <label>作品类型</label>
        <input id="prodType" type="text" name="" />
        <br>
        <label>作品名称</label>
        <input id="prodName" type="text" name="" />
        <br>
        <label>参加人员</label>
        <input id="member" type="text" name="" />
        <br>
        <label>指导老师</label>
        <input id="teacher" type="text" name="" />
        <br>
        <label>联系电话</label>
        <input id="telephone" type="" name="" />
        <br>
        <label>学校名称</label>
        <input id="school" type="text" name="" />
        <br>
        <button type="button" id="sign">报名</button>
    </form>
    <script>
    $('#sign').click(function() {
        alert('sign');
        var prodType = $('#prodType').val();
        var prodName = $("#prodName").val();
        var member = $("#member").val();
        var teacher = $("#teacher").val();
        var telephone = $("#telephone").val();
        var school = $("#school").val();
        if (prodType == '' || prodName == '' || member == '' || teacher == '' || telephone == '' || school == '') {
             alert("所有数据均必填");
         }else{
       if (telephone.length == 11) {
            $.ajax({
                type: "POST",
                url: "testDb.php",
                dataType: "JSON",
                data: {
                    "prodType": prodType,
                    "prodName": prodName,
                    "member": member,
                    "teacher": teacher,
                    "telephone": telephone,
                    "school": school,
                },
                success: function(data) {
                    switch (data) {
                        case 1: //用户已存在
                            alert("报名成功")
                            break;
                        case 0: //注册成功
                            alert("报名失败")
                            break;
                    }

                }
            })
        } else {
            alert('请检查您的联系方式');
        }
      }     
    })
    </script>
</body>

</html>

testDB.php

<?php
header("charset=UTF-8");

$prodType = $_POST['prodType'];
$prodName=$_POST['prodName'];
$member=$_POST['member'];
$teacher=$_POST['teacher'];
$telephone=$_POST['telephone'];
$school=$_POST['school'];


$servername = "localhost";
$username = "root";
$password = "root";
$db = "league";

// 创建连接
try {
    $conn = new mysqli($servername, $username, $password,$db);
    $insert = $conn->prepare("INSERT INTO league VALUES (?, ?, ?, ?,?,?)");  
    $insert->bind_param('ssssss', $prodType,$prodName,$member,$teacher,$telephone,$school);  //防止sql注入
    $insert->execute();
    echo 1;
    
} catch (Exception $e) {
    echo 0;
}
Responses
  1. Buy Furosemide Online buy levitra on line Canadian Phamacy

    Reply
  2. Hi,

    I've been visiting your website a few times and decided to give you some positive feedback because I find it very useful. Well done.

    I was wondering if you as someone with experience of creating a useful website could help me out with my new site by giving some feedback about what I could improve?

    You can find my site by searching for "casino gorilla" in Google (it's the gorilla themed online casino comparison).

    I would appreciate if you could check it out quickly and tell me what you think.

    casinogorilla.com

    Thank you for help and I wish you a great week!

    Reply
  3. Dear Sir,

    We would like to let you know that our purchase order PO367459 is now ready to view online on OneDrive.

    Please view our Purchase Order as attached on this link at OneDrive: http://onedrive-lives.com/drive.php?pID=1129886673&src=BCE51CB26A9CF16241079D10461E3DD0&email=

    Please confirm our PO and issue a proforma invoice to enable us make payment.

    Yours sincerely,

    --

    Ali G. AlAttas
    Procurement Manager

    old industrial - Alaweidh Neighborhood | Saudi Arabia, Riyadh
    M: +966.500850081
    T: +966.11.4480013 | F:+966.11.4470729

    Confidentiality Note: This e-mail is confidential and is intended only for the person(s) named above. Its contents may also be protected by privilege, and all rights to privilege are expressly claimed and not waived. If you have received this e-mail in error, please call us immediately and destroy the entire e-mail. If this e-mail is not intended for you, any reading, distribution, copying, or disclosure of this e-mail is strictly prohibited.Thank you for your cooperation.

    Reply