0

this is my poll code i'm getting data in Mysql

<form role="form" action="graduating_students_preview.php" method="post">
  <h3 class="style"> Student Performa</h3>



      <p>Department:</p>

        <select name="depart" required class="depart form-control btn-primary" >     
           <option value="">Department </option>
            <option value="computer science">Computer Science</option>
           <option value="zoology">Zoology</option>

  </select>

 <p>Degree</p>

  <select name="degree" class="degree form-control btn-primary" required > 
    <option value=""> Degree </option>
     <option value="computer science">Computer Science</option>
      <option value="chemistry">Chemistry</option>
       <option value="BBA">BBA</option>                          
  </select>


  <p>Semester</p>
 <select class="form-control btn-primary" name="semester" required>
  <option value="">semester</option>
       <option value="1st">FIRST (01)</option>
       <option value="2nd">SECOND (02)</option>
      <option value="3rd">THIRD (03)</option>
         <option value="4th">FOURTH (04)</option>
         <option value="05">FIFTH (05)</option>
        <option value="06">SIX (06)</option>
      <option value="07">SEVEN(07)</option>
       <option value="08">EIGHT (08)</option>
  </select></td>


       <p>Study Year</p>
  <select class="form-control btn-primary" name="study_year" required>
  <option value="" style="font-size:8px;">Select_year </option>
  <option value="2014" label="2014">2014</option>
  <option value="2013" label="2013">2013</option>
  <option value="2012" label="2012">2012</option>
  <option value="2011" label="2011">2011</option>
  <option value="2010" label="2010">2010</option>
  </select>


  <p>Faculty</p>

      <select name="faculty" class="faculty form-control btn-primary" required>
         <option value="">Faculty</option>
         <option value="science">Science</option>
         <option value="Arts geg">Arts</option>
         </select><br/>


         <div class="container">

      <p style="font-weight:bold">1. The work in the Program is too Heavy and induces a lot of 
     pressure</p>
        <div class="radio">
          <label><input type= "radio"  name = "q1" value="very satisfied">very satisfied</label>
        </div>
         <div class="radio">
          <label><input type= "radio"  name= "q1" value="satisfied">satisfied</label>
        </div>
         <div class="radio">
          <label><input type= "radio"  name="q1" value="uncertain">uncertain</label>
        </div>

and this is my PHP code

$db_name="performa";  // your database name  
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect"); //mysql connection  
mysql_select_db("$db_name")or die("can not select DB"); //select your database 
error_reporting(E_ALL ^ E_NOTICE); 
$depart = $_POST['depart'];  
$degree = $_POST['degree'];  
$semester = $_POST['semester']; 
$study_year = $_POST['study_year'];
$faculty = $_POST['faculty'];
$query = "INSERT INTO performa1 (depart,degree,semester,study_year,faculty) VALUES ('$depart', '$degree', '$semester', '$study_year', '$faculty')";  
mysql_query($query) or die('Query "' . $query . '" failed: ' . mysql_error());  
// name, email and address are fields of your fields; test your table. $name, $email and $address are values collected from the form  
?>  

this is working fine in website but i want to use it in intel xdk and intel xdk dont support PHP/Mysql but we can do it with AJAX with JQUERY call PHP file i'm trying to do it but i dont know how to do it correctly so can anyone tell me where to place PHP file and how to do it with AJAX or different procedure i just want to get the data into database
Thanks

  • **Danger**: You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are also **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/quessations/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Dec 04 '14 at 07:13
  • what should i add in this code ? newbee in PHP – faraz aslam Dec 04 '14 at 07:25
  • It should replace the existing code you are using to access the database with. – Quentin Dec 04 '14 at 07:29

2 Answers2

0

You can't run PHP or MySQL on most phones or tablets, so it doesn't make sense for a development kit targeting them to "support" them.

Write your server side code as a separate project. Then put the URL to an instance of that in your mobile app.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • any idea using javascript to get information of this poll in txt file(XML) or other resources . i'm using intel xdk for HTML5 application . – faraz aslam Dec 04 '14 at 07:22
  • You've recognised that you need to use Ajax. There are many Ajax tutorials that you can find with Google or other search engines. You might want to look for a Cordova specific one. – Quentin Dec 04 '14 at 07:30
0

I dont really undestand what you want to achieve: The title says 'AJAX to call remote files'. If you want to send a request to the web server you need to set up this options on the jquery ajax:

xhrFields: {
     withCredentials: true
    },
crossDomain: true


You need cross domain access to request the web server because intel xdk apps internally they are a web server and that will give you cross domain error on the request.

Another thing you say 'i just want to get the data into database' if you want to send the data to the database you just only need to send a request sending the form fields to the php file which have the procedure or query to be executed. If you have your html and php form together I recommend you to separate your server side code from your client side code. This will help you on maintenance in the future with bigger sites.

revobtz
  • 606
  • 10
  • 12