I also facing the same problem, I already debug and everything looks fine. 
Could it be a server response ?

On Sunday, December 6, 2015 at 6:09:11 PM UTC+8, AbdulMajeed Mohammad wrote:
>
> Hi,
>
> I have problem with sending data from app to mysql by php file, I hope to 
> get some help
> I don't know also if I did it in right way,
>
> contact.java
>
> public class Contact extends AppCompatActivity {
>
>     EditText name,phone,email,subject;
>     Button add;
>     RequestQueue requestQueue;
>     String addUrl = "http://10.0.2.2/alruthea/contact/addcontact.php";;
>
>     @Override
>     protected void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.activity_contact);
>         getSupportActionBar().setDisplayShowCustomEnabled(true);
>         getSupportActionBar().setCustomView(R.layout.actionbar);
>
>         name = (EditText) findViewById(R.id.contactname);
>         phone = (EditText) findViewById(R.id.contactphone);
>         email = (EditText) findViewById(R.id.contactemail);
>         subject = (EditText) findViewById(R.id.contactsubject);
>         add = (Button) findViewById(R.id.contactsend);
>
>
>         requestQueue = Volley.newRequestQueue(getApplicationContext());
>
>
>     add.setOnClickListener(new View.OnClickListener() {
>         @Override
>         public void onClick(View view) {
>             StringRequest request = new StringRequest(Request.Method.POST, 
> addUrl, new Response.Listener<String>() {
>                 @Override
>                 public void onResponse(String response) {
>
>                 }
>             }, new Response.ErrorListener() {
>                 @Override
>                 public void onErrorResponse(VolleyError error) {
>
>                 }
>             }) {
>                 @Override
>                 protected Map<String, String> getParams() throws 
> AuthFailureError {
>                     Map<String, String> parameters = new HashMap<String, 
> String>();
>                     parameters.put("name", name.getText().toString());
>                     parameters.put("phone", phone.getText().toString());
>                     parameters.put("email", email.getText().toString());
>                     parameters.put("subject", subject.getText().toString());
>
>                     return parameters;
>                 }
>             };
>             requestQueue.add(request);
>         }
>
>     });
>
>
>     }
>
> }
>
>
>
> connection.php
>
> <?php
>
> define('hostname','localhost');
> define('user' , 'root');
> define('password','');
> define('databaseName','alruthea');
>
> $connect = mysqli_connect(hostname, user, password, databaseName);
>
> ?>
>
>
>
>
>
> addcontact.php
>
> <?php
>
> if($_SERVER["REQUEST_METHOD"]=="POST"){
>        require 'alruthea/contact/connection.php';
>        createContact();
>        }
>        
>        function createcontact()
>        {
>        global $connect;
>        
>        $name = $_POST["name"];
>        $phone = $_POST["phone"];
>        $email = $_POST["email"];
>        $subject = $_POST["subject"];
>        
>        $query = "Insert into contact(name,phone,email,subject) values 
> ('$name;,'$phone','$email','$subject');";
>        
>        mysqli_query($connect, $query) or die (mysqli_error($connect));
>        mysqli_close($connect);
>        }
>
>        ?>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/ad591b4c-999c-4191-a1e5-2cd0b8ce4ca1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to