0

mySQL DB のテーブルのいくつかのフィールドを更新する html フォームを作成しました。更新が成功した後、成功ページに移動する必要があります。それ以外の場合は、エラー メッセージが表示されます。エラーを示す

フォーム検証を使用していますが、これまでのところ、テーブルのフィールドに何も起こらず、空白のページに移動するだけです

フォームコードは次のとおりです。

<html>
    <body>
    <form action="http://localhost/wordpress/orgupdate.php" method="post" name="myForm">
        Name <input id="name" type="text" name="name" />
        Telephone <input id="telephone" type="text" name="telephone" />
        Fax <input id="fax" type="text" name="fax" />
        Web address <input id="webaddress" type="text" name="webaddress" />
        State <input id="state" type="text" name="state" />
        Address <input id="address" type="text" name="address" />
        <input type="submit"  name= "submit" value="update" />
    </form>
    </body>
</html>


<script type="text/javascript">// <![CDATA[
    /* JS validation code here */

    function validateForm()
    {
        /* Validating name field */
        var x=document.forms["myForm"]["name"].value;
        if (x==null || x=="")
        {
            alert("Name must be filled out");
            return false;
        }
        /* Validating email field */
        var x=document.forms["myForm"]["telephone"].value;

        if (x==null || x=="")
        {
            alert("telephone must be filled out");
            return false;
        }
    }
// ]]>
</script>

これは私のphpファイルです:

<?php 
//establish connection
$con = mysqli_connect("localhost","xx","xxxx","android_app"); 
//on connection failure, throw an error
if(!$con) {  
    die('Could not connect: '.mysql_error()); 
}

//get the form elements and store them in variables
$name=$_POST['name']; 
$telephone=$_POST['telephone']; 
$fax=$_POST['fax']; 
$webaddress=$_POST['webaddress']; 
$state=$_POST['state']; 
$address=$_POST['address'];

$query= update  islamic_organisation SET (Telephone ='$telephone', Fax ='$fax', WebAddress ='$webaddress', state ='$state', Address ='$address' WHERE  Name  ='$name');

//Redirects to the specified page
header("Location: http://localhost/wordpress/?page_id=857");
?>

何か案が ?

4

2 に答える 2