2016-10-22 5 views
0

私はphonegapを使ってモバイルアプリを作成するのが初めてです。だから私は小さなフォームを作成しようとしているときに、ユーザーが送信データをServersFree.comで作成したオンラインサーバーに移動する必要がありますphongapアプリとウェブサーバーのデータベースを接続するには

私はファイルマネージャにのみ、私は携帯電話のビルドを使用してAPKファイルを作成した後、私は自分の携帯電話に入れようとしているhtmlファイルからアクセスします。それを行う正しい方法ですか?

<?php 
$servername = "hin123.bugs3.com"; 
$username = "u137593186"; 
$password = "ulsdjj29822"; 
$dbname = "u137593186_user"; 

$conn = new mysqli($servername, $username, $password, $dbname); 

if ($conn->connect_error) { 
die("Connection failed: " . $conn->connect_error);} 

$name = $_POST['Name']; 
$age = $_POST['Age']; 
$username = $_POST['username']; 
$password = $_POST['password']; 

$sql = "INSERT INTO user (name, age, username, password) 
VALUES ('$name', '$age','$username','$password')"; 

if ($conn->query($sql) === TRUE) { 
    echo "New record created successfully"; 
} else { 
    echo "Error: " . $sql . "<br>" . $conn->error; 
} 

$conn->close(); 
?> 

これは、同じフォルダ内にあなたの両方のファイルは、その後、ちょうど

<form action="insert.php" method="post"> 

を使用することは、ローカルの両方のために働く場合は、[はい、あなたがURLまたは を変更する必要が私のhtmlファイル

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

<link rel="stylesheet" type="text/css" href="css/register.css" /> 

<title>Registration</title> 
</head> 

<body> 

    <form id='register' action='insert.php' method='POST'> 
     <fieldset > 
     <legend>Register</legend> 

     <form action="" method="post"> 
     <label>Name :</label> 
     <br></br> 
     <input id="Name" name="Name" type="text"> 
     <br></br> 
     <label>Age :</label> 
     <br></br> 
     <input id="Age" name="Age" type="text"> 
     <br></br> 
     <label>UserName :</label> 
     <br></br> 
     <input id="username" name="username" placeholder="username" type="text"> 
     <br></br> 
     <label>Password :</label> 
     <br></br> 
     <input id="password" name="password" placeholder="**********" type="password"> 
     <br></br> 
     <input name="submit" type="submit" value="Submit"> 
     <br></br> 

     <span><?php echo $error; ?></span> 
     </form> 

</body> 
</html> 
+0

アクション= "insert.php" このコードを試してみてください。あなたのファイルの場所に基づいてそれを変更します。 'no localhost' ..... – Karthi

答えて

0

<form action="insert.php" method="post"> 
関連する問題