$_POST is empty

Hello, I’m new to PHP dev and am playing around with some basic things. I have a simple form that (should) take a submitted email and print a user’s information, retrieved from the db, to the page.

My form code is as follows:

[php]<?php
$page_title = ‘Account management tool mock up’;
include (‘header.html’);

?>

Enter an email address:

<?php include ('footer.html'); ?>[/php]

The code at the top of “user_deets.php” is as follows:

[php]<?php
$page_title = ‘User details’;
include (‘header.html’);

require_once (’./scripts/connect.php’);

echo ‘

’ . $_POST . ‘
’;

if (isset($_POST[‘email_submitted’])) {…

…} else {
echo ‘

User not found

’;
}[/php]

All I get on the page is:

Array

User not found

Anyone know what I seem to be doing wrong? Any help is appreciated.

There is no tag in the actual code…must’ve posted an older version when I was still building out the CSS w/ placeholders

Actually, the page is loading the script in the if statement, but all info I’m trying to echo from the db is blank and the echo ‘

’ . $_POST . ‘
’; still just prints “Array”.

[php]

<?php $page_title = 'Account management tool mock up'; include_once ('header.html'); ?>

Enter an email address:

<?php include_once('footer.html'); ?> [/php]

what is this for ?

How about echo

[php]echo ‘

’ . $_POST[‘email’] . ‘
’;[/php]

You need to sanatise your post to if its not already being done.

[php]echo ‘

’ . $_POST[‘email’] . ‘
’;[/php]

Thanks…this does print the email address entered in the form. The tag was just a left over placeholder; I took it out of the code.

Now I’m having trouble at the next step…

[php]$sub_email = trim($_POST[‘email’]);
$q = “SELECT CONCAT(first_name, last_name) AS name, acct_type AS at, DATE_FORMAT(act_date, ‘%M %d, %Y’) AS ad FROM users WHERE email=” . $sub_email;
$r = mysqli_query ($dbc, $q);

$row = mysqli_fetch_array($r, MYSQLI_ASSOC);
echo '<div id="content">' . $row["name"] . '</div>';[/php]

I’m getting this error returned: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in …/user_deets.php on line 18

My first question is whether or not the WHERE clause in the SQL query is correct? Secondly, what might be causing this error message?

do you have mysqli enabled in php.ini?

Sponsor our Newsletter | Privacy Policy | Terms of Service