I have a iphone application when the user presses the button i collect data and send it to web server that is written by php.I made a form there and of course my form has a submit button but when the user press the button in the application how can i tell the form to submit the text that user choses. here is my php code
<?php require_once('Connections/local.php')?>
<?php
if (isset($_POST['appy_level'])){
$id=mysql_insert_id();
$appy_level=$_POST['appy_level'];
$year=$_POST['year'];
$date =date('Y');
$year=$date-$year;
$reasons = $_POST['reasons'];
$reasons = str_replace(","," ",$reasons);
if(isset($_POST['sex']))
$sex=$_POST['sex'];
$country=$_POST['country'];
$city=$_POST['city'];
$id=mysql_insert_id();
$insertSQL = "INSERT INTO user (age,wname,slid,time,sex) VALUES (".$year.",".$reasons.",".$appy_level.",CURRENT_TIMESTAMP,".$sex.")";
$insertSQL1="INSERT INTO country (c_name) VALUES (".$country.")";
$insertSQL2="INSERT INTO city (ci_name) VALUES (".$city.")";
mysql_select_db($database_local, $local);
mysql_query($insertSQL, $local) or die(mysql_error());
mysql_query($insertSQL1, $local) or die(mysql_error());
mysql_query($insertSQL2, $local) or die(mysql_error());
}
?>
<body>
<form action="" method="post" name="form1" id="form1">
<table>
<tr>
<td>Happyness level:</td>
<td>
<input type="text" name="appy_level" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Reasons:</td>
<td>
<input type="text" name="reasons" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input type="text" name="sex" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Country:</td>
<td>
<input type="text" name="country" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>City:</td>
<td>
<input type="text" name="city" value="" maxlength="100" />
</td>
</tr>
<tr>
<td>Year:</td>
<td>
<input type="text" name="year" value="" maxlength="100" />
</td>
</tr>
<tr><td> </td>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</table>
</body>
How can i submit my form without a submit button. when the user presses the button ok in iphone application i want to submit his information to database.
I do not see where you are connecting to your database, the connection you are trying to use is
$local, here:If the values you are trying to insert are strings, you need to enclose them in single quotes:
You should wrap the string values in quotes and not forget to protect against sql injection by escaping the strings: