I am presently working on a form. It was working fine until I changed the form code thus: echo “”; from: echo “”;
Now the form shows up in the browser but will not recognize the data entered. I enter the data and click “submit” then the data disappears and the form remains.
Please do not refer me to a tutorial as I have been stuck on this problem for 9 weeks now and it seems every tutorial or any help I looked at just seems to ramble on and on and on and it means nothing to me. I realize that if someone can just do the code for me then I will understand. Until then its hopeless in trying to explain to me in PHP jargon. All I require is that someone to give me the correct code(s) to make this thing work. If someone chooses to help I will attach my codes then as I needed to explain my situation first.
I just registered so I am not familiar with using attachments and will have to read up on it.
Thank you for your kind understanding
Here’s a simple form that might help you understand a little bit better:
[code]
Login
Username:
Password:
[/code]
If you want to have it go to the same page, in this case login.php then name it login.php and put the php code above the <?DOCTYPE html> (ABOVE THE HTML).
Like so:
[php]<?php
if (isset($_POST[‘action’]) && $_POST[‘action’] == ‘login’) {
// Then you code goes here:
// A little example:
$query = 'SELECT id, userType, username, email, pass FROM users WHERE username=:username';
$stmt = $pdo->prepare($query);
$stmt->execute(array(':username' => $_POST['username']));
$stmt->setFetchMode(PDO::FETCH_CLASS, 'Member');
$stored_user_data = $stmt->fetch();
// More code goes here:
// Once you get what you want done with the code the redirect the user to something like the following?
header('Location:memberOnlyPage.php');
exit();
} // I use a hidden input instead of the submit for I find it more reliable
?>[/php]
Remember if you want it to go to the same page, I would simply call it the same name that is in the form action. I hope this helps a little bit or makes it a little bit clearer. Now, I have to add this statement for I have in the past people take my code to be the literal answer to their coding problem, obviously the code I shown for the example will not work properly nor is intended to, its sole purpose is to help you understand the principal of a basic HTML form.