http php request insert


I have a j2me file which allows the user to regester by entering their name and password. when they press submit it connects to a url:http://localhost/SMSRegistration.php and sends the information:


I need a php file to pick up the password and enter it into a SQL database, I am using phpmyadmin.

The problem is that it is not picking it up or it is not inserting it into the database? Is there any way to print the incoming value so that I know if the j2me file is actually sending the info?

the j2me file sends the data like this:
// Create the connection
http = (HttpConnection) + “?password=” + password);

System.out.println(url + “?password=” + password);
// 1) Send request method

Here is my php file, it is very basic:

<?php if (isset($_REQUEST['password'])) { // create short variable names $password=$_REQUEST['password']; $db_conn = mysql_connect('localhost', 'root'); mysql_select_db('auth', $db_conn); $query = "insert into auth value ('".$password."')"; if (!$db) { echo 'Error: Could not connect to database. Please try again later.'; exit; } } ?>


print_r() on $_REQUEST will print out the array’s structure and values, but you should simply validate your entry using a regular expression or even isset() (if you don’t really care about what they enter).

For security reasons, you should send a post request from Java instead of writing the password directly in the URL. Using some encryption would also be a good thing. You’re script should read the value using $_POST instead of $_REQUEST, that way you can be sure where the data is coming from.

By the way, you’re using MySQL, not phpMyAdmin. phpMyAdmin is only a frontend for the database.