how to use if else statement in php/Html programming languages - php

I am new in PhP. i am trying to use if/else statement to request for (include 'user_index_Big_Data.php';) with different inputs.
when I run the code it will output all the .php forms. but i just want it to output just one form.
<html>
<head>
<LINK href="style.css" rel="stylesheet" type="text/css">
<title>Login</title>
</head>
<body>
<form action="" method="post">
<h1>Enter Key word to search</h1>
<p>Search <input type="text" name="username" placeholder='e.g. big data, Big Data'></p>
<p><input type="submit" name="submit" value="Search"></p>
</form>
</body>
</html>
<?php
$user = ("Big Data" || "big data" or "Big data" or "BIG DATA" or "big data analytics" or "BIG DATA ANALYTICS"
or "big data analysis");
$user1 = ("machine learning" || "MACHINE LEARNING" or "Machine Learning" or "Machine learning");
$user2 = ("Data center" || "Efficient Energy" or "Renewal Energy" or "Multi-Agents");
//$pass = "itsme";
if(isset($_POST["submit"])) {
if($_POST["username"] == $user )
include 'user_index_Big_Data.php';}
if(isset($_POST["submit"])) {
if($_POST["username"] == $user1 )
include 'user_index_machine_Learning.php';
}
if(isset($_POST["submit"])) {
if($_POST["username"] == $user3 )
include 'Energy.php';
}
else {
echo "Incorrect Key Word";
}
?>
please i want the code to output just one form. but it outputs all the forms. it echos all the results of the forms.

If you add the various key-words to arrays you can test for a match using in_array ~ though there is no need to include all possible uppercase/lowercase variants, just cast supplied user data to lowercase etc
<html>
<head>
<link href='style.css' rel='stylesheet' />
<title>Login</title>
</head>
<body>
<?php
if( $_SERVER['REQUEST_METHOD']=='POST' && !empty( $_POST['type'] ) ){
/* Process secondary form submission - do whatever needs to be done with secondary forms */
ob_clean();
$_POST['time']=time();
exit( json_encode( $_POST ) );
}
if( $_SERVER['REQUEST_METHOD']=='POST' && isset( $_POST['submit'], $_POST['username'] ) ){
/* Process primary form to select secondary form */
$file=false;
$user=array('big data','big data analytics');
$user1=array('machine learning');
$user2=array('data center','efficient energy','renewal energy','multi-agents');
$username=trim( strtolower( urldecode( $_POST['username'] ) ) );
if( in_array( $username, $user ) )$file='user_index_Big_Data.php';
if( in_array( $username, $user1 ) )$file='user_index_machine_Learning.php';
if( in_array( $username, $user2 ) )$file='Energy.php';
if( $file ){
if( file_exists( $file ) )require $file;
else printf( 'Unable to find file: "%s" to suit username "%s"', $file, $_POST['username'] );
} else {
printf( 'Incorrect Key Word: "%s"', $_POST['username'] );
}
}
?>
<form method='post'>
<h1>Enter Key word to search</h1>
<p>Search <input type='text' name='username' placeholder='e.g. big data, Big Data'></p>
<p><input type='submit' name='submit' value='Search'></p>
</form>
</body>
</html>
The other, secondarary, forms:
<?php
/* Big Data : user_index_Big_Data.php */
?>
<form name='big-data' method='post'>
<input type='text' name='type' value='big data' />
<input type='submit' />
</form>
<?php
/* machine learning : user_index_machine_Learning.php */
?>
<form name='machine-learning' method='post'>
<input type='text' name='type' value='machine learning' />
<input type='submit' />
</form>
<?php
/* Energy : energy.php */
?>
<form name='energy' method='post'>
<input type='text' name='type' value='Energy' />
<input type='submit' />
</form>

Related

my php diff checker code works fine on a single word but not in the sentences

I am writing a php program to compare two strings of equal length and highlight the difference.
My code works fine on single words. But when I enter a sentence to compare, then it prints out the html parts of my code in unusual manner.
<form action="#" method="post">
<input type="text" name="first"><br>
<input type="text" name="second"><br>
<input type="submit" name="">
</form>
<?php
$var1=$_POST['first'];
$var2=$_POST['second'];
echo $var1;
echo "<br>";
$var3=$var2;
$temp =$var2;
$diff_char1='';
for ($i=0;$i<strlen($var1);$i++) {
// code...
if ($var1[$i]==$var2[$i]) {
// code...
// echo "true<br>";
}
else{
// code...
$diff_char = substr($var2, $i,1);
//echo"<br>".$diff_char;
$diff_char1='<span style="background:red">'.$diff_char.'</span>';
//echo $diff_char1.'<br>';
$temp= str_replace($diff_char,$diff_char1,$temp);
//echo $temp."<br>";
}
}
echo $temp;
?>
Rather than modifying the content as you process the string you could simply build a new string that reflects the differences and present that at the end to show the differences - perhaps like this:
<?php
error_reporting( E_ALL );
?>
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title></title>
<style>
output span{color:red}
</style>
</head>
<body>
<form method="post">
<input type="text" name="first" />
<input type="text" name="second" />
<input type="submit" />
</form>
<output>
<?php
if( $_SERVER['REQUEST_METHOD']=='POST' && isset(
$_POST['first'],
$_POST['second']
)){
$first=$_POST['first'];
$second=$_POST['second'];
$message='';
if( substr_compare( $first, $second, 0 )===0 ){
$message='Strings are identical';
} elseif( strlen( $first )!=strlen( $second ) ){
$message='Strings are of different lengths';
}else{
for( $i=0; $i < strlen( $first ); $i++ ){
$chr1=substr($first,$i,1);
$chr2=substr($second,$i,1);
if( $chr1!==$chr2 )$message.=sprintf('<span>%s</span>',$chr2);
else $message.=$chr1;
}
}
echo $message;
}
?>
</output>
</body>
</html>

php wont direct me to the 'action' page

I have two pages which are (sigin.php , validateIn.php)
the form the is submitted by the user in the 'signin' page, then gets validated in the 'validateIn' page.
The problem is that the server doesn't redirect me to the 'validateIn' page and it just reloads the current page 'signin'.
I have included the action attribute in the form tag.
I have tried using the header('Location:***.php) function
none of these worked for me.
I have included a number of "echo" statements to know the path of the compiler.
Signin.php
<form action="validateIn.php" method="POST">
<strong> <label> Student Number: </strong>
<input id="studentNumber" type="text" name="studentNumber"
value="<?php echo isset($_POST['studentNumber']) ? $_POST['studentNumber'] : '' ?>">
</label> <br>
<strong> <label> Password: </strong>
<input id="pass" type="password" name="pass">
</label> <br>
<input id="signin" type="submit" name="signin" value="Sign In" >
</form>
vaildateIn.php
<?php
if (isset($_POST['signin'])) { //if 1
echo "if number 1 <br>";
if(!empty($_POST['studentNumber']) && !empty($_POST['pass']) ){ //if 2
echo "if number 2";
$number = mysqli_real_escape_string($_POST['studentNumber']);
$pass = mysqli_real_escape_string(md5($_POST['pass']));
$sql = "SELECT * FROM students WHERE student_number=$number AND password=$pass";
$result = mysqli_query($$conn, $sql);
if (mysqli_num_rows($result) == 1) { //if 3
echo "if number 3";
header('Location:home.php');
} else { //else 1
echo "else number 1";
header('Location:signin.php');
}
}
}
else{
echo "else number 2";
}
To add the hashed version of the user's password to the database, semi-pseudo code might be:
<form method='post'>
<label>username:<input type='text' name='username' /></label>
<label>studentNumber:<input type='text' name='studentNumber' /></label>
<label>password:<input type='password' name='pass' /></label>
<input type='submit' />
</form>
<?php
if( $_SERVER['REQUEST_METHOD']=='POST' ){
$args=array(
'studentNumber' => FILTER_SANITIZE_STRING,
'username' => FILTER_SANITIZE_STRING,
'pass' => FILTER_SANITIZE_STRING
);
$_POST=filter_input_array( INPUT_POST, $args );
extract( $_POST );
$pwdhash=password_hash( $pass, PASSWORD_DEFAULT );
$sql='insert into `student` set `username`=? `student_number`=?, `password`=?';
$stmt=$db->prepare( $sql );
$stmt->bind_param('sss', $username, $studentNumber, $pwdhash );
$stmt->execute();
}
?>
If you were to assume that passwords had been stored in the database as correctly formed hashes using password_hash then the approach you would use to verify the user credentials could be like this:
<form action="validateIn.php" method="POST">
<label>
<strong>Student Number: </strong>
<input type="text" name="studentNumber" value="<?php echo isset( $_POST['studentNumber'] ) ? $_POST['studentNumber'] : '' ?>" />
</label>
<br />
<label>
<strong>Password:</strong>
<input type="password" name="pass" />
</label>
<br />
<input type="submit" value="Sign In" />
</form>
if( $_SERVER['REQUEST_METHOD']=='POST' ){
$args=array(
'studentNumber' => FILTER_SANITIZE_STRING,
'pass' => FILTER_SANITIZE_STRING
);
$_POST=filter_input_array( INPUT_POST, $args );
extract( $_POST );
if( isset( $studentNumber, $pass ) ){
$sql='select `password` from `student` where `student_number`=?';
$stmt=$db->prepare( $sql );
$stmt->bind_param( 's', $studentNumber );
$res=$stmt->execute();
if( $res ){
$stmt->store_result();
$stmt->bind_result( $pwdhash );
$stmt->fetch();
$stmt->free_result();
$stmt->close();
if( $pwdhash == password_verify( $pass, $pwdhash ) ){
/* ok - redirect accordingly */
}else{
/* bogus - */
}
}
}
}
With regards to the logic used in your form and validateIn.php script - this appears to work fine for me ( removed all the db calls though ) - hope this all proves of some help but I will say that you are wrong to assume that security is not important in your project as it is just a school exercise.... never too early to adopt best practise '-)
<?php
if( $_SERVER['REQUEST_METHOD']=='POST' ){
/* POST to same page to emulate posting to validateIn.php */
if( isset( $_POST['signin'] ) ) {
echo "if number 1 <br>";
if( isset( $_POST['studentNumber'], $_POST['pass'] ) && !empty( $_POST['studentNumber'] ) && !empty( $_POST['pass'] ) ){
echo "if number 2";
} else {
echo 'Bogus - empty or missing fields';
}
} else{
echo "else number 2";
}
}
?>
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title></title>
</head>
<body>
<form method="POST">
<label>
<strong>Student Number: </strong>
<input type="text" name="studentNumber" value="<?php echo isset( $_POST['studentNumber'] ) ? $_POST['studentNumber'] : '' ?>" />
</label>
<br />
<label>
<strong>Password:</strong>
<input type="password" name="pass" />
</label>
<br />
<input type="submit" name='signin' value="Sign In" />
</form>
</body>
</html>

Add items to the array through a form using Php

I need to add items to my existing array through a form on the site i made.
Basically once i submit something on my form it needs to add the item to the array, i can only use php and html for this problem.
i tried array_push but it doesnt give me what i need because it doesnt use the form
<form action="" method="post">
<input type="text" name="boodschappen"><br><br>
<input type="submit" value="Verstuur">
</form>
<ul>
<?php
$boodschappen = ["aardappelen","aardbeien","3 pakken melk","yoghurt"];
foreach ($boodschappen as $boodschap) {
echo "<li>".$boodschap."</li>";
}
?>
</ul>
</body>
</html>
<?php
$post = $_POST;
$boodschappen = ["aardappelen","aardbeien","3 pakken melk","yoghurt"];
$result = array_merge($post, $boodschappen);
foreach ($result as $item) {
echo "<li>".$item."</li>";
}
<?php
$a=array("red","green");
array_push($a,"blue","yellow");
echo "<pre>";
print_r($a);
?>
If I understand your code correctly, you'll need some sort of persistent storage to store all the previous submission in the listing. A database would be ideal for long term storage. Session would be the minimal requirement:
<?php
session_start();
if (!isset($_SESSION['past_submission']) || !is_array($_SESSION['past_submission'])) {
$_SESSION['past_submission'] = [];
}
if (!empty($_POST) && isset($_POST['boodschappen']) && !empty(trim($_POST['boodschappen']))) {
array_push($_SESSION['past_submission'], $_POST['boodschappen']);
}
$past_submission = $_SESSION['past_submission'];
?>
<html>
<body>
<form action="" method="post">
<input type="text" name="boodschappen"><br><br>
<input type="button" value="Verstuur">
</form>
<ul>
<?php
$boodschappen = ["aardappelen","aardbeien","3 pakken melk","yoghurt"];
array_push($boodschappen, ...$past_submission);
foreach ($boodschappen as $boodschap) {
echo "<li>".$boodschap."</li>";
}
?>
</ul>
</body>
</html>
Please note that Session only works for the visitor session alone. The data is not available to other visitors or you.
As described before, you'd probably need a MariaDB / MySQL / PostgreSQL to store the submissions for long term. You'd probably need to use PDO to insert data into, or retrieve data from database.
Perhaps like this?
<html>
<head><title></title></head>
<body>
<form action="" method="post">
<input type="text" name="boodschappen"><br><br>
<input type="submit" value="Verstuur">
</form>
<ul>
<?php
$boodschappen = ["aardappelen","aardbeien","3 pakken melk","yoghurt"];
if( $_SERVER['REQUEST_METHOD']=='POST' && !empty( $_POST['boodschappen'] ) ){
$boodschappen=array_merge( $boodschappen, explode(' ', $_POST['boodschappen'] ) );
}
foreach( $boodschappen as $boodschap ) {
echo "<li>".$boodschap."</li>";
}
?>
</ul>
</body>
</html>
To update the array with persistance you can use a session variable like so:
<?php
session_start();
if( !isset( $_SESSION['boodschappen'] ) ){
$_SESSION['boodschappen']=["aardappelen","aardbeien","3 pakken melk","yoghurt"];
}
?>
<html>
<head>
<title></title>
</head>
<body>
<form action="" method="post">
<input type="text" name="boodschappen"><br><br>
<input type="submit" value="Verstuur">
</form>
<ul>
<?php
if( $_SERVER['REQUEST_METHOD']=='POST' && !empty( $_POST['boodschappen'] ) ){
$items=explode(' ', $_POST['boodschappen'] );
foreach( $items as $item )$_SESSION['boodschappen'][]=$item;
}
foreach( $_SESSION['boodschappen'] as $boodschap ) {
echo "<li>".$boodschap."</li>";
}
?>
</ul>
</body>
</html>
<?php session_start(); ?>
<ul>
<?php
if (!empty($_POST['submit'])) {
$_SESSION['boodschappen'][] = $_POST['boodschap'];
foreach ($_SESSION['boodschappen'] as $boodschap) {
echo "<li>".$boodschap."</li>";
}
} else {
$_SESSION['boodschappen'] = [];
}
?>
</ul>
<form action="" method="post">
<input type="text" name="boodschap"><br>
<input type="submit" name="submit" value="Verstuur">
</form>

What am I doing wrong with this phone SESSION I'm trying to print to screen?

I am testing a SESSION where the three prior pages prints to the last page. But I'm have trouble getting it to work. Everything goes well until the last page. Here is the code:
<?php
session_start();
if (isset($_POST['submit'])) {
$_SESSION['name'] = $_POST ['name'];
$_SESSION['email'] = $_POST ['email'];
$_SESSION['age'] = $_POST ['age'];
echo $_SESSION['name'];
echo $_SESSION['email'];
echo $_SESSION['age'];
}
?>
I'm getting a blank or a index error for the session variable. Can anyone help with the correct way to print user inputted session data?
These are the 1st, 2nd and 3rd pages:
<html>
<head>
<title>phpsession</title>
</head>
<body>
<form method="POST" action="test_2_page_1.php">
<input type="text" name="name" placeholder="enter name"></input>
<input type="submit"> next</input>
</form>
<?php
//Set session variables
if (isset($_POST['submit'])) {
$_SESSION['name'] = $_POST ['name'];
}
?>
</body>
</html>
<?php
session_start();
if (isset($_POST['submit'])) {
$_SESSION['name'] = $_POST ['name'];
$_SESSION['email'] = $_POST ['email'];
}
?>
<html>
<head>
<title>phpsession</title>
</head>
<body>
<form method="POST" action="test_2_page_2.php">
<input type="text" name="email" placeholder="enter email"></input>
<input type="submit"> next</input>
</form>
<?php
// Set session variables
?>
</body>
</html>
<?php
session_start();
if (isset($_POST['submit'])) {
$_SESSION['name'] = $_POST ['name'];
$_SESSION['email'] = $_POST ['email'];
$_SESSION['age'] = $_POST ['age'];
}
?>
<html>
<head>
<title>phpsession</title>
</head>
<body>
<form method="POST" action="post_test.php">
<input type="text" name="age" placeholder="enter age"></input>
<input type="submit"> next</input>
</form>
<?php
// Set session variables
?>
</body>
</html>
The input element is self-closing in that you do not need </input> - rather the tag is simply closed using />
To display Next as the submit button you would use the value attribute - ie: <input type='submit' value='Next' />
Once the session variable is assigned you do not need to keep trying to set it and will encounter errors if the variable is not available in the POST array - so use isset to test prior to creating a variable
<?php
session_start();
if ( isset( $_POST['submit'], $_POST['name'] ) ) {
$_SESSION['name'] = $_POST['name'];
}
?>
<html>
<head>
<title>phpsession</title>
</head>
<body>
<form method="POST" action="test_2_page_1.php">
<input type="text" name="name" placeholder="enter name" />
<input type="submit" name='submit' value='Next'>
</form>
</body>
</html>
<?php
session_start();
if ( isset( $_POST['submit'], $_POST['email'] ) ) {
$_SESSION['email'] = $_POST['email'];
}
?>
<html>
<head>
<title>phpsession</title>
</head>
<body>
<form method="POST" action="test_2_page_2.php">
<input type="text" name="email" placeholder="enter email" />
<input type="submit" name='submit' value='Next'>
</form>
</body>
</html>
<?php
session_start();
if( isset( $_POST['submit'],$_POST['age'] ) ) {
$_SESSION['age'] = $_POST['age'];
}
?>
<html>
<head>
<title>phpsession</title>
</head>
<body>
<form method="POST" action="post_test.php">
<input type="text" name="age" placeholder="enter age" />
<input type="submit" name='submit' value='Next'>
</form>
</body>
</html>
To further help you solve your issues I quickly put together a single page demo of getting and setting the session variables based upon form submissions.. hope it'll help
<?php
session_start();
#https://stackoverflow.com/questions/54194496/what-am-i-doing-wrong-with-this-phone-session-im-trying-to-print-to-screen/54194890?noredirect=1#comment95217192_54194890
if( !empty( $_GET['reset'] ) ){
unset( $_SESSION['name'] );
unset( $_SESSION['email'] );
unset( $_SESSION['age'] );
header( sprintf('Location: %s', $_SERVER['SCRIPT_NAME'] ) );
}
/*
as each form only submits two values ( submit being one ) we can
simply remove it from the POST array and use the remaining field/value
to generate the session variables using simple array techniques
The below could easily be replaced with pre-defined variables, such as:
if( isset( $_POST['name'] ) )$_SESSION['name']=$_POST['name']; etc
*/
if ( isset( $_POST['submit'] ) ) {
/* remove the submit button & value from the array */
unset( $_POST['submit'] );
/* there will now be one item, with index = 0 */
$keys=array_keys( $_POST );
$values=array_values( $_POST );
/* set the session variable */
$_SESSION[ $keys[0] ]=$values[0];
}
?>
<html>
<head>
<title>phpsession</title>
</head>
<body>
<form method='POST'>
<?php
if( empty( $_SESSION['name'] ) ){
echo "<input type='text' name='name' placeholder='enter name' />";
}
if( !empty( $_SESSION['name'] ) && empty( $_SESSION['email'] ) ){
echo "<input type='text' name='email' placeholder='enter email address' />";
}
if( !empty( $_SESSION['name'] ) && !empty( $_SESSION['email'] ) && empty( $_SESSION['age'] ) ){
echo "<input type='text' name='age' placeholder='enter your age' />";
}
if( empty( $_SESSION['age'] ) ){
echo "<input type='submit' name='submit' value='Next'>";
} else {
if( empty( $_POST['finish'] ) ) echo "<input type='submit' name='finish' value='Finish'>";
}
if( isset( $_POST['finish'] ) ){
/*
Once the user has completed each form, send them off to their final destination?
or do something else....
*/
printf(
'Do some interesting stuff now ....
<pre>%s</pre>Reset',
print_r( $_SESSION, true )
);
}
?>
</form>
</body>
</html>
You have no input element in your HTML with the name submit so the following part of your PHP code will always evaluate to false:
if (isset($_POST['submit'])) {
Change the submit button in your HTML to the following and the line above will evaluate to true when the form is posted:
<input name="submit" type="submit"> next</input>

Insert query not working in MySQL , PHP

Here is my code to insert data in MySQL as Back-end and PHP as front-end
Connection is established properly but insert query is not working neither it is showing any error as per the else conditions at the end after insert query
It is not reaching inside the $_POST['submit'] too.
<html>
<head></head>
<title></title>
<body>
<form type="post" name="addimage" enctype="multipart/form-data" >
Album Name<input type="text" name="albumname">
<input type="file" name="filesToUpload" id="filesToUpload" multiple=""/>
</p>
Client Name<input type="text" name="clientname">
<br>Location<input type="text" name="location">
<button type="submit" value="submit" name="submit" id="submit">Submit</button>
</body>
</form>
</html>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "apostrophe";
$con=mysqli_connect("localhost","root","","apostrophe");
mysqli_select_db($con,"apostrophe");
if(isset($_POST['submit']))
{
echo "reached";
$albumname=$_REQUEST['albumname'];
$images=$_REQUEST['filesToUpload'];
$client=$_REQUEST['clientname'];
$loc=$_REQUEST['loc'];
echo "reached submit";
$sql="INSERT INTO album(albumname,images,clientname,location)VALUES('$albumname','$albumname','$client','$loc')";
echo "reached down";
if($con->query($sql)===TRUE)
{
echo "Success";
}
else
echo "Failed";
}
?>
The original code has quite a few errors in ( the form straddles the body, wrong declaration for form method, title outside the head etc ) and there is no attempt at handling the actual uploaded images. Hopefully the following ought to give you a headstart with getting the file handling piece completed - though no doubt I have missed something too '-)
<?php
$status='';
/* Might as well test that all necessary fields are included in form submission */
if( isset( $_POST['submit'], $_POST['albumname'], $_POST['clientname'], $_POST['location'] ) ){
/* only need to declare the db connection if the variables are set */
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "apostrophe";
/* create the db conn */
$con=mysqli_connect("localhost","root","","apostrophe");
/* at least some basic filtering if you intend to place user submitted content directly in the sql */
$albumname=strip_tags( filter_input( INPUT_POST,'albumname',FILTER_SANITIZE_STRING ) );
$client=strip_tags( filter_input( INPUT_POST,'clientname',FILTER_SANITIZE_STRING ) );
$loc=strip_tags( filter_input( INPUT_POST,'location',FILTER_SANITIZE_STRING ) );
/* handle file uploads */
$fieldname='filesToUpload';
foreach( $_FILES[$fieldname]['name'] as $i => $name ) {
if( !empty( $_FILES[$fieldname]['tmp_name'][$i] ) ) {
$filename = $_FILES[$fieldname]['name'][$i];
$size = $_FILES[$fieldname]['size'][$i];
$type = $_FILES[$fieldname]['type'][$i];
$tmpfile = $_FILES[$fieldname]['tmp_name'][$i];
/* copy file to final destination - this is not complete!! */
$bytes=move_uploaded_file( $tmpfile, '/path/to/final/directory/'.$filename );
/* to debug uncomment below */
#echo $filename,$tmpfile,$size,$type;
}
}
/* prepare and execute sql */
$sql="INSERT INTO `album` ( `albumname`, `images`, `clientname`, `location` ) VALUES ( '$albumname', '$albumname', '$client', '$loc' )";
/* set status variable to be displayed under form */
$status=( $con->query( $sql )===TRUE ) ? "Success" : "Failed";
} else {
$status='bad foo';
$status=print_r( $_POST, true );
}
?>
<html>
<head>
<title>File upload and database inserts</title>
</head>
<body>
<form method="post" name="addimage" enctype="multipart/form-data" >
Album Name<input type="text" name="albumname">
<input type="file" name="filesToUpload[]" id="filesToUpload" multiple=""/>
Client Name<input type="text" name="clientname">
<br>
Location<input type="text" name="location">
<button type="submit" value="submit" name="submit" id="submit">Submit</button>
</form><?php echo $status; ?>
</body>
</html>
Change your line :
<form type="post" name="addimage" enctype="multipart/form-data">
to
<form method="post" name="addimage" enctype="multipart/form-data">

Categories