Jump to content

Form processing mysql


Lambneck

Recommended Posts

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>

 

 

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.