Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PHP
<?php <br mode="hold" /?>
if(isset($_POST['submit']))
{
	/***********************************************************************
	Your Sample Code is here
	***********************************************************************/
	//This makes sure they did not leave any field blank
	if(!$_POST['Username']|!$_POST['Password']|!$_POST['F_Name']|!$_POST['L_Name']|
	!$_POST['Gender']|!$_POST['year']|!$_POST['month']|!$_POST['day']|!$_POST['street']|
	!$_POST['City']|!$_POST['Code']|!$_POST['Country']|!$_POST['Email']|)
	{
	die('You did not complete all of the required fields');
	} 
	
	/********************************************************************************************************************************
	My Changes are here	*********************************************************************************************************************************/
	
	if(empty($_POST['Username']) || empty($_POST['Password']))
	{
		die('You did not complete all of the required fields');
	}
}
?>
Posted
Updated 26-Dec-20 5:39am
v2
Comments
enhzflep 15-Nov-12 3:25am    
You want us to count lines for you?
Edit your question, indicate the line that has a problem in it.
Following that, actually ASK a question.
My 1.
CodingLover 15-Nov-12 3:42am    
What you have on line 12?

VB
if(!$_POST['Username']|!$_POST['Password']|!$_POST['F_Name']|!$_POST['L_Name']|
    !$_POST['Gender']|!$_POST['year']|!$_POST['month']|!$_POST['day']|!$_POST['street']|
    !$_POST['City']|!$_POST['Code']|!$_POST['Country']|!$_POST['Email']|)


You have an | at the end so it says |). That's the issue. It expects another condition before the ), you don't have too many brackets.
 
Share this answer
 
Hi thanks it worked and gone through but the database connection now is the one giving an errors:
Unidentified variable username in C:wamp\Adulteducation\DatabaseConn.php on line 8
Unidentified variable password in C:wamp\Adulteducation\DatabaseConn.php on line 8
Unidentified variable host in C:wamp\Adulteducation\DatabaseConn.php on line 8
The numbers are the lines. Thanks, I will appreciate i am a novice to php so I am trying to learn.


1. 2. //Database connection
3. $db_host ="localhost";
4. $db_user ="root";
5. $db_password ="";
6. $db_database ="e-farmer portal";
7.
8. $connection=mysql_connect($host,$username,$password);
9. mysql_select_db("smith auto") or die(mysql_error());
10. ?>
 
Share this answer
 
Comments
DinoRondelly 15-Nov-12 12:17pm    
Where did you declare $host,$Username,$Password?

Unidentified variable username means that the variable username isnt declared.

If i had to guess if you changed line 8 to look like the line below it would work
$connection = mysql_connect($db_host,$db_user,$db_passowrd)
DinoRondelly thanks but am I missing something on the code below, I am getting the error:
Parse error: syntax error, unexpected '[' in C:\wamp\www\AdultEducation\index.php on line 11

line 11 is the one in bold. Kindly assist. I appreciate the effort.

/*
This page authenticate users before they can acccess their protected pages
only registered Consumers can login. The idea and the concept:
http://www.phpeasystep.com/workshopview.php?id=6
*/
//Starting a session
session_start();
echo 'Welcome to Farmer Broker';

$_SESSION['username']=['username'];

//Connection to the Database
require ('DatabaseConn.inc.php');
//This code runs if the the form has been submitted
if(isset($_POST['submit'])){
//Username and Password sent from the form
$username=$_POST['Username'];
$password=$_POST['Password'];

//To protect MySQL injection
$user=stripslashes($user);
$passwd=stripslashes($password);
$user=mysql_real_escape_string($user);
$password=mysql_real_escape_string($password);

//Retrieving information from the table
$sql="SELECT Username,Password,Status FROM Consumer
WHERE Username='$user' AND Password=password('$password')";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);

//Mysql num row is counting table row
$count=mysql_num_rows($result);

//If result matched $username and $password, table row must be 1 row
if($count==1){
if($row["Status"]=='Verify'){
header ("location:Verify.php");
}else{
header ("location:Home.php");}
}
else{
//If the username and/or the password is wrong the error message is displayed
$msg="Invalid Username and/or Password";
}
}
?>
 
Share this answer
 
Make sure you have PHP >= 7.0.0 on your system. I'm guessing perhaps your command line PHP version isn't the same as the one your web server uses. Make sure your php-cli is also at 7+
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900