Lambneck Posted July 25, 2012 Share Posted July 25, 2012 Upon submission of a simple form which should store user information in a mysql database, it instead does not submit any information and leaves the user at a blank page with the url site.com/php/processor.php ...Connection variables are assigned in load_data.php There are no error messages; nothing but white pixels. <?php if ( isset($_POST['submit']) ) { require_once('load_data.php'); if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database" . mysql_error()); if (!mysql_select_db($database)) die("Can't select database" . mysql_error()); $title = mysql_real_escape_string($_POST['title']); $post = mysql_real_escape_string($_POST['post']); $address = mysql_real_escape_string($_POST['address']); $ip = $_SERVER['REMOTE_ADDR']; $insert = mysql_query("INSERT INTO $table (title, post, address, user_ip) VALUES ('$title', '$post', '$address', '$ip')") or die(mysql_error()); } header('Location: ../index.php'); exit(); ?> <form action="php/processor.php" method="post"> <fieldset> <legend>Submit</legend> <ol> <li> <label>Title</label> <input id="title" name="title" type="text"> </li> <li> <label>Post</label> <textarea id="post" name="post" rows=5 required></textarea> </li> <li class="hidden"> <label>Address</label> <input id="address" name="address" type="text"> </li> </ol> </fieldset> <fieldset> <button>Address</button> <button>Picture</button> <input type="submit" value="Post It"> </fieldset> </form> Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/ Share on other sites More sharing options...
peipst9lker Posted July 25, 2012 Share Posted July 25, 2012 Place this 3 lines on top of your processor.php You should see errors then. If not check your error.log of the webserver. (Linux default Apache2 error.log: $ watch tail /var/log/apache2/error.log) error_reporting(E_ALL | E_STRICT); ini_set('display_errors', 1); ini_set('html_errors', 1); Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/#findComment-1364230 Share on other sites More sharing options...
lordshoa Posted July 25, 2012 Share Posted July 25, 2012 I cannot really see anything wrong with it. But you send them to action="php/processor.php" so you need to redirect them with the header after processor.php? or post to the same page as form or use sessions ? Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/#findComment-1364232 Share on other sites More sharing options...
Pikachu2000 Posted July 25, 2012 Share Posted July 25, 2012 To start with, $_POST['submit'] will never exist in the $_POST array because your submit button has no name attribute. Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/#findComment-1364235 Share on other sites More sharing options...
Lambneck Posted July 25, 2012 Author Share Posted July 25, 2012 Added three lines to the top of processor and name attribute to submit button. No change in result. Still no error message. Also checked server error logs and there was nothing relating to this issue. Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/#findComment-1364240 Share on other sites More sharing options...
Pikachu2000 Posted July 25, 2012 Share Posted July 25, 2012 Is the data inserted into the database? Add some echoes to the processing code to help see what it's doing. Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/#findComment-1364241 Share on other sites More sharing options...
Lambneck Posted July 25, 2012 Author Share Posted July 25, 2012 Tried echoing variables from within processor.php including those from the load_data.php and nothing is displayed. Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/#findComment-1364258 Share on other sites More sharing options...
Lambneck Posted July 25, 2012 Author Share Posted July 25, 2012 omfg it was the file collation. Changed the file encoding to utf-8 and worked perfectly Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/#findComment-1364324 Share on other sites More sharing options...
hakimserwa Posted July 25, 2012 Share Posted July 25, 2012 post your code again lets see. it has ever happened to me delet the baton input and put it again. Quote Link to comment https://forums.phpfreaks.com/topic/266221-form-processing-mysql/#findComment-1364329 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.