php image file is not copying in the folder - php

This is error showing page.i cant find any clues why showing these errors. The image file is not copying the images folder.
Notice: Undefined index: image in C:\xampp\htdocs\Project\Manpower.php on line 36
Notice: Undefined index: image in C:\xampp\htdocs\Project\Manpower.php on line 38
Warning: copy(): Filename cannot be empty in C:\xampp\htdocs\Project\Manpower.php on line 38
<?php
include_once'db_connect.php';
session_start();
$mysqli = new mysqli("localhost", "root", "", "travelagent");
if(isset($_POST['status']))
{
if (!isset($_SESSION["username"]))
{
$message = "please login!!";
echo "<script type='text/javascript'>alert('$message');</script>";
}
else
{
$id = mysqli_real_escape_string($mysqli, $_POST['id']);
$username=$_SESSION["username"];
$_SESSION['id']=$id;
$sql = "UPDATE product SET status='1' WHERE id='$id' " ;
if(mysqli_query($mysqli,$sql)==true)
{
$image_path= mysqli_real_escape_string( $mysqli ,'images/'.$_FILES['image']['name']);
if(copy($_FILES['image']['tmp_name'],$image_path))
{
$_SESSION['image']=$image_path;
$image=$_SESSION['image'];
$sql="INSERT INTO cart (user_name, product_id,image) VALUES ('$username','$id','$image')";
$result=$mysqli->query($sql);
$message = "added to cart!! ";
echo "<script type='text/javascript'>alert('$message');</script>";
session_destroy();
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Polyworld Services</title>
<meta name="Description" content="Polyworld">
<meta name="viewport" content="width:device-width" initial-scale="1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script
src="https://code.jquery.com/jquery-2.2.4.js"
integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="
crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/full-slider.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body data-spy="scroll" data-target="#my-navbar">
<?php
include'header.php';
?>
<h1 style="text-align:center;">Welcome to Manpower page</h1>
<div class="row" id="content">
<?php
$result=$mysqli->query("SELECT * FROM product WHERE category_id='1' AND sub_category_id='1' AND status='0'" );
while($row=$result->fetch_array())
{
?>
<div class="col-md-3">
<ul>
<li>picture : <?php echo "<img src='admin/".$row['image']. "' height='200' width='200'>"; ?> </li>
<li>Name: <?php echo $row['name']; ?></li>
<li>Description :<?php echo $row['description']; ?></li>
<li >Details</li>
<form action="" method="post">
<input type="text" name="id" value="<?php echo $row['id']; ?>">
<input type="hidden" name="image" value="<?php echo $row['image']; ?>">
<li><input type="submit" name="status" value="add to cart"></li></br>
</form>
</ul>
</div>
<?php
}
?>
</div>
<?php include'footer.php'; ?>
<script type="text/javascript">
</script>
</script>
<script type="text/javascript" src="js/custom.js">
</script>
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</body>
</html>

Try this code to upload file
$dir="image/";//name of the folder where the file need to be copied
$file=$dir . basename($_FILES["photo"]["name"]);// where 'photo' is the field name of file input
$filetype=pathinfo($file,PATHINFO_EXTENSION);
if(move_uploaded_file($_FILES["photo"]["tmp_name"], $file)) {
echo "upload success";
}

Related

Bulk Email Validator works but not properly

I wish to either make use of a freely available email validator (software, script or online service). There's work but when I insert more than one email at that time only one email verifies which I insert last and other email does not verify. Only one email verifies. How can I do it?
My code:
<?php
include_once('config.php');
if(isset($_POST["email_verify_btn"])) {
$email = $_POST["email_verify"];
if(strpos($email,"\n")) {
$text = explode("\n",$email);
} else {
$text = array($email);
}
function domain_exists($text)
{
$domain = substr(strrchr($text, "#"), 1);
$arr = #dns_get_record($domain, DNS_MX);
if ($arr[0]['host'] == $domain && !empty($arr[0]['target'])) {
return $arr[0]['target'];
}
}
foreach ($text as $abc) {
$domain = "";
$target = "";
$target_ip = "";
if(filter_var($abc, FILTER_VALIDATE_EMAIL)) {
if(domain_exists($abc)){
$domain = substr(strrchr($abc, "#"), 1);
$data = #dns_get_record($domain, DNS_MX);
if (is_array($data) || is_object($data)) {
foreach ($data as $key1) {
$host = $key1['host'];
$target = $key1['target'];
$target_ip = gethostbyname($key1['target']);
}
}
if($data) {
$status = "email id is valid";
}
} else {
$status = "mx recored not exist";
}
} else {
$status = "not in syntax";
}
$c_by = 1;
$c_date = date('Y-m-d H:i:s');
$c_ip = $_SERVER['REMOTE_ADDR'];
$insert = $connect->query("INSERT INTO `email_verify_list`(`primary_email`,`host_name`,`target`,`target_ip`,`session`,`status`,`created_by`, `created_date`, `created_ip`) VALUES ('$abc','$domain','$target','$target_ip','$c_date','$status','$c_by','$c_date','$c_ip')");
if($insert == 1) {
$_SESSION['date_time'] = $c_date;
} else {
echo "<script>alert('!!!!!not successfully');</script>";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<meta charset="utf-8"/>
<title>BULK EMAIL VARIFIER</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"/>
<link rel="apple-touch-icon" href="pages/ico/60.png">
<link rel="apple-touch-icon" sizes="76x76" href="pages/ico/76.png">
<link rel="apple-touch-icon" sizes="120x120" href="pages/ico/120.png">
<link rel="apple-touch-icon" sizes="152x152" href="pages/ico/152.png">
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta content="" name="description"/>
<meta content="" name="author"/>
<link href="assets/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/bootstrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/switchery/css/switchery.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="pages/css/pages-icons.css" rel="stylesheet" type="text/css" />
<link class="main-stylesheet" href="pages/css/pages.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 9]>
<link href="assets/plugins/codrops-dialogFx/dialog.ie.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
</head>
<body class="fixed-header ">
<div id="rootwizard" class="m-t-50">
<ul class="nav nav-tabs nav-tabs-linetriangle nav-tabs-separator nav-stack-sm">
<li class="active">
<a data-toggle="tab" href="#tab1"><span>EMAIL VERIFY</span></a>
</li>
</ul>
<form method="post" action="" >
<div class="tab-content">
<div class="tab-pane padding-20 active slide-left" id="tab1">
<div class="row row-same-height">
<div class="col-md-12">
<div class="padding-30">
<div class="row clearfix">
<div class="col-sm-3">
<div class="form-group form-group-default">
<label><font size="2">ENTER YOUR EMAIL <span class="glyphicon glyphicon-envelope"></span></font></label><br>
<textarea cols="43" rows="9" name="email_verify" style="border-color:white;border-width:thin;padding:4pt;" multiple/></textarea><br>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-3">
<button type="submit" name="email_verify_btn" class="btn btn-lg btn-info" style="padding:11pt;width:200px;"/><span><b><font size="2">SUBMIT</font></b></span></button>
</div>
</div> <br><br>
<div class="row clearfix">
<div class="col-sm-12">
<table width="100%" class="table ">
<tr class="success">
<th>PRIMARY EMAIL <span class="glyphicon glyphicon-envelope"></span></th>
<th>HOST NAME</th>
<th>TARGET</th>
<th>TARGET IP</th>
<th>STATUS</th>
</tr>
<?php
$select = $connect->query("SELECT * from `email_verify_list` where session='".$_SESSION['date_time']."' order by id");
while($row = $select->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['primary_email']; ?></td>
<td><?php echo $row['host_name']; ?></td>
<td><?php echo $row['target']; ?></td>
<td><?php echo $row['target_ip']; ?></td>
<td><?php echo $row['status']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script src="assets/plugins/pace/pace.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="assets/plugins/modernizr.custom.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrapv3/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery/jquery-easy.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-bez/jquery.bez.min.js"></script>
<script src="assets/plugins/jquery-ios-list/jquery.ioslist.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-actual/jquery.actual.min.js"></script>
<script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script type="text/javascript" src="assets/plugins/classie/classie.js"></script>
<script src="assets/plugins/switchery/js/switchery.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap3-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-autonumeric/autoNumeric.js"></script>
<script type="text/javascript" src="assets/plugins/bootstrap-tag/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-inputmask/jquery.inputmask.min.js"></script>
<script src="assets/plugins/bootstrap-form-wizard/js/jquery.bootstrap.wizard.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script>
<script src="assets/plugins/summernote/js/summernote.min.js" type="text/javascript"></script>
<script src="assets/plugins/moment/moment.min.js"></script>
<script src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="assets/plugins/bootstrap-timepicker/bootstrap-timepicker.min.js"></script>
<script src="pages/js/pages.min.js"></script>
<script src="assets/js/form_wizard.js" type="text/javascript"></script>
<script src="assets/js/scripts.js" type="text/javascript"></script>
<script src="assets/js/demo.js" type="text/javascript"></script>
<script>
window.intercomSettings = {
app_id: "xt5z6ibr"
};
</script>
</body>
</html>
I think , you are not using strpos function in correct way.
you can use this way . Because strpos return also 0 value if any string found at zero position . and return FALSE if search string not found
Also note that string positions start at 0, and not 1.
if(strpos($email,"\n")!==false) {
$text = explode("\n",$email);
} else {
$text = array($email);
}

there is error of Fatal error: Cannot redeclare domain_exists();

I have error when trying to insert data in databse, i get the following message:
Notice: Undefined variable: host in C:\wamp64\www\email_verify\index.php on line 53
Notice: Undefined variable: target in C:\wamp64\www\email_verify\index.php on line 53
Notice: Undefined variable: target_ip in C:\wamp64\www\email_verify\index.php on line 53
Fatal error: Cannot redeclare domain_exists() (previously declared in C:\wamp64\www\email_verify\index.php:13) in C:\wamp64\www\email_verify\index.php on line 13
how can i solve it....?
<?php
include_once('config.php');
if(isset($_POST["email_verify_btn"])) {
$email = $_POST["email_verify"];
if(strpos($email,"\n")) {
$text = explode("\n",$email);
foreach ($text as $abc) {
function domain_exists($abc)
{
$domain = substr(strrchr($abc, "#"), 1);
$arr = #dns_get_record($domain, DNS_MX);
if ($arr[0]['host'] == $domain && !empty($arr[0]['target'])) {
return $arr[0]['target'];
}
}
if(domain_exists($abc)){
$domain = substr(strrchr($fetch_email, "#"), 1);
$data = #dns_get_record($domain, DNS_MX);
if($data) {
$status = "email id is valid";
}
if (is_array($data) || is_object($data)) {
foreach ($data as $key1) {
$host = $key1['host'];
$target = $key1['target'];
$target_ip = gethostbyname($key1['target']);
}
}
} else {
$status = "mx recored not exist";
}
$c_by = 1;
$c_date = date('Y-m-d H:i:s');
$c_ip = $_SERVER['REMOTE_ADDR'];
$insert = $connect->query("INSERT INTO `email_verify_list`(`primary_email`,`host_name`,`target`,`target_ip`,`session`,`created_by`, `created_date`, `created_ip`) VALUES ('$abc','$host','$target','$target_ip','$c_ip','$c_by','$c_date','$c_ip')");
if($insert) {
$_SESSION['date_time'] = $c_date;
echo "<script>alert('successfully');</script>";
} else {
echo "<script>alert('!!!!!not successfully');</script>";
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<meta charset="utf-8"/>
<title>BULK EMAIL VARIFIER</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"/>
<link rel="apple-touch-icon" href="pages/ico/60.png">
<link rel="apple-touch-icon" sizes="76x76" href="pages/ico/76.png">
<link rel="apple-touch-icon" sizes="120x120" href="pages/ico/120.png">
<link rel="apple-touch-icon" sizes="152x152" href="pages/ico/152.png">
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta content="" name="description"/>
<meta content="" name="author"/>
<link href="assets/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/bootstrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/switchery/css/switchery.min.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="pages/css/pages-icons.css" rel="stylesheet" type="text/css" />
<link class="main-stylesheet" href="pages/css/pages.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 9]>
<link href="assets/plugins/codrops-dialogFx/dialog.ie.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
</head>
<body class="fixed-header ">
<div id="rootwizard" class="m-t-50">
<ul class="nav nav-tabs nav-tabs-linetriangle nav-tabs-separator nav-stack-sm">
<li class="active">
<a data-toggle="tab" href="#tab1"><span>EMAIL VERIFY</span></a>
</li>
</ul>
<form method="post" action="" >
<div class="tab-content">
<div class="tab-pane padding-20 active slide-left" id="tab1">
<div class="row row-same-height">
<div class="col-md-12">
<div class="padding-30">
<div class="row clearfix">
<div class="col-sm-3">
<div class="form-group form-group-default">
<label><font size="2">ENTER YOUR EMAIL <span class="glyphicon glyphicon-envelope"></span></font></label><br>
<textarea cols="43" rows="9" name="email_verify" style="border-color:white;border-width:thin;padding:4pt;" multiple/></textarea><br>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-3">
<button type="submit" name="email_verify_btn" class="btn btn-lg btn-info" style="padding:11pt;width:200px;"/><span><b><font size="2">SUBMIT</font></b></span></button>
</div>
</div> <br><br>
<div class="row clearfix">
<div class="col-sm-12">
<table width="100%" class="table ">
<tr class="success">
<th>PRIMARY EMAIL <span class="glyphicon glyphicon-envelope"></span></th>
<th>HOST NAME</th>
<th>TARGET</th>
<th>TARGET IP</th>
<th>STATUS</th>
</tr>
<?php
$select = $connect->query("SELECT * from `email_verify_list` where session='".$_SESSION['date_time']."' order by id");
while($row = $select->fetch_assoc()) {
?>
<tr>
<td><?php echo $row['primary_email']; ?></td>
<td><?php echo $row['host_name']; ?></td>
<td><?php echo $row['target']; ?></td>
<td><?php echo $row['target_ip']; ?></td>
<td><?php echo $row['status']; ?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script src="assets/plugins/pace/pace.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="assets/plugins/modernizr.custom.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrapv3/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery/jquery-easy.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-bez/jquery.bez.min.js"></script>
<script src="assets/plugins/jquery-ios-list/jquery.ioslist.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-actual/jquery.actual.min.js"></script>
<script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script type="text/javascript" src="assets/plugins/classie/classie.js"></script>
<script src="assets/plugins/switchery/js/switchery.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap3-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-autonumeric/autoNumeric.js"></script>
<script type="text/javascript" src="assets/plugins/bootstrap-tag/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-inputmask/jquery.inputmask.min.js"></script>
<script src="assets/plugins/bootstrap-form-wizard/js/jquery.bootstrap.wizard.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script>
<script src="assets/plugins/summernote/js/summernote.min.js" type="text/javascript"></script>
<script src="assets/plugins/moment/moment.min.js"></script>
<script src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
<script src="assets/plugins/bootstrap-timepicker/bootstrap-timepicker.min.js"></script>
<script src="pages/js/pages.min.js"></script>
<script src="assets/js/form_wizard.js" type="text/javascript"></script>
<script src="assets/js/scripts.js" type="text/javascript"></script>
<script src="assets/js/demo.js" type="text/javascript"></script>
<script>
window.intercomSettings = {
app_id: "xt5z6ibr"
};
</script>
</body>
</html>
Don't declare the function inside the loop.
Put this:
function domain_exists($abc)
{
$domain = substr(strrchr($abc, "#"), 1);
$arr = #dns_get_record($domain, DNS_MX);
if ($arr[0]['host'] == $domain && !empty($arr[0]['target'])) {
return $arr[0]['target'];
}
}
... before this line:
foreach ($text as $abc) {
Next, you need to declare the variables $target and $target_ip on the same level as you're trying to use them, i.e. on the same level as this line:
$insert = $connect->query("INSERT INTO `email_verify_list`(`primary_email`,`host_name`,`target`,`target_ip`,`session`,`created_by`, `created_date`, `created_ip`) VALUES ('$abc','$host','$target','$target_ip','$c_ip','$c_by','$c_date','$c_ip')")

Not getting the reason for the error [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 8 years ago.
There are quite a few solutions available for this error but none seems to be working for me. I am a new php developer and trying to create web site using php programs.
The error I'm getting is "Warning: Cannot modify header information - headers already sent by (output started at /home/influss/public_html/Influsstest/hiremain.php:39) in /home/influss/public_html/Influsstest/hiremain.php on line 74"
I have checked the line no. 39 and do not find any whitespace before or after the php. also there are no white spaces in the beginning or the end of the program but still I'm getting this error.
the code is as follows:
`
<!doctype html>
<html><!-- InstanceBegin template="/Templates/registrtion.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Hire Main</title>
<!-- InstanceEndEditable -->
<link href="/css/styles-reg.css" rel="stylesheet" type="text/css" media="all">
<link href="/css/reg.css" rel="stylesheet" type="text/css" media="all"/>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Raleway:400,600,900,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Slabo+13px' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'>
<!-- InstanceBeginEditable name="head" -->
<link href="css/styles.css" rel="stylesheet" type="text/css" media="all">
<!-- InstanceEndEditable -->
</head>
<body>
<div id="wrapper">
<div id="top">
<div id = "logo">
<img src="images/logo2.jpg">
</div>
<div id = "social-media">
<p>For additional information<br>Call Phone No.</p>
<ul>
<li><img src="/images/icons/facebook1.png"></li>
<li><img src="/images/icons/twitter1.png"></li>
<li><img src="/images/icons/linkedin1.png"></li>
<li><img src="/images/icons/googleplus1.png"></li>
</ul>
</div>
</div>
<!-- <div id="Banner">
</div>
--> <div id="Content-wrapper">
<div id="content">
<!-- InstanceBeginEditable name="content" -->
**<?php**
error_reporting(E_ALL); ini_set('display_errors', 'On');
function renderForm($id, $error)
{
?>
<?php
if ($error != '')
{
echo '<div style="margin:0 200px;padding:4px; color:red ;font-weight:bold;">'.$error.'</div>';
}
?>
<form action="hiremain.php" method="post" class="newreg">
<fieldset class="row1">
<p>
<label class="labelstyle">Enter Registration ID: *</label>
<input type="text" name="regid" value="<?php echo $id;?>"/>
</p>
</fieldset>
<p></p>
<input class="button1" type="submit" name="submit" value="Get Details">
</form>
<p></p>
<?php
}
?>
<?php
include('connect.php');
if (isset($_POST['submit']))
{
$id = $_POST['regid'];
$sql = "Select * from hirefinal where hr_id = '$id'";
$result = mysql_query($sql) or die(mysql_error());
$total_results = mysql_num_rows($result);
if ($total_results > 0)
{
header('location:hireedit.php?regid='.$id);
}
else
{
$id = $_POST['regid'];
$sql = "Select * from hirefinal where hr_id = '$id'";
$result = mysql_query($sql) or die(mysql_error());
$total_results = mysql_num_rows($result);
if ($total_results > 0)
{
header("location:hireedit.php?regid=" . $id);
}
Else
{
$error = "Please register first";
renderForm($id, $error);
}
}
mysql_free_result($result);
}
else
{
$error = "";
$id="";
renderform($id, $error);
}
?>
Register a Request
Home
<p></p>
<!-- InstanceEndEditable -->
</div>
</div>
<div id="footer">
<p>©Copyright 2014 • All rights Reserved • Influss.com, Chennai, Mob: +9112345-12345, E-mail: abc#influss.com</p>
</div>
</div>
</body>
<!-- InstanceEnd -->
</html>
`
The error happens to be in the line which is marked by *.
Request somebody help me out on this.
You can't send headers after an html output.
You have to put them before
<!doctype html>
You can resolve this using:
<?php
error_reporting(E_ALL); ini_set('display_errors', 'On');
function renderForm($id, $error)
{
if ($error != '')
{
$problems = '<div style="margin:0 200px;padding:4px; color:red ;font-weight:bold;">'.$error.'</div>';
}
}
include('connect.php');
if (isset($_POST['submit']))
{
$id = $_POST['regid'];
$sql = "Select * from hirefinal where hr_id = '$id'";
$result = mysql_query($sql) or die(mysql_error());
$total_results = mysql_num_rows($result);
if ($total_results > 0)
{
header('location:hireedit.php?regid='.$id);
}
else
{
$id = $_POST['regid'];
$sql = "Select * from hirefinal where hr_id = '$id'";
$result = mysql_query($sql) or die(mysql_error());
$total_results = mysql_num_rows($result);
if ($total_results > 0)
{
header("location:hireedit.php?regid=" . $id);
}
Else
{
$error = "Please register first";
renderForm($id, $error);
}
}
mysql_free_result($result);
}
else
{
$error = "";
$id="";
renderform($id, $error);
}
?>
<!doctype html>
<html><!-- InstanceBegin template="/Templates/registrtion.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Hire Main</title>
<!-- InstanceEndEditable -->
<link href="/css/styles-reg.css" rel="stylesheet" type="text/css" media="all">
<link href="/css/reg.css" rel="stylesheet" type="text/css" media="all"/>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Raleway:400,600,900,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Slabo+13px' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Rokkitt:400,700' rel='stylesheet' type='text/css'>
<!-- InstanceBeginEditable name="head" -->
<link href="css/styles.css" rel="stylesheet" type="text/css" media="all">
<!-- InstanceEndEditable -->
</head>
<body>
<div id="wrapper">
<div id="top">
<div id = "logo">
<img src="images/logo2.jpg">
</div>
<div id = "social-media">
<p>For additional information<br>Call Phone No.</p>
<ul>
<li><img src="/images/icons/facebook1.png"></li>
<li><img src="/images/icons/twitter1.png"></li>
<li><img src="/images/icons/linkedin1.png"></li>
<li><img src="/images/icons/googleplus1.png"></li>
</ul>
</div>
</div>
<!-- <div id="Banner">
</div>
--> <div id="Content-wrapper">
<div id="content">
<!-- InstanceBeginEditable name="content" -->
<?php
echo $problems;
?>
<form action="hiremain.php" method="post" class="newreg">
<fieldset class="row1">
<p>
<label class="labelstyle">Enter Registration ID: *</label>
<input type="text" name="regid" value="<?php echo $id;?>"/>
</p>
</fieldset>
<p></p>
<input class="button1" type="submit" name="submit" value="Get Details">
</form>
<p></p>
Register a Request
Home
<p></p>
<!-- InstanceEndEditable -->
</div>
</div>
<div id="footer">
<p>©Copyright 2014 • All rights Reserved • Influss.com, Chennai, Mob: +9112345-12345, E-mail: abc#influss.com</p>
</div>
</div>
</body>
<!-- InstanceEnd -->
</html>

"Index.php?webpage" Not Functioning properly

So I am trying to access a certain webpage within my site.
In my index, I use a isset($_GET() parameter to access another page. My code for the index.php is as follows:
<!DOCTYPE html>
<html>
<head>
<?php require ("includes/database.php"); ?>
<title>Offstreams Admin Panel</title>
<link rel="stylesheet" type="text/css" href="styles/admin_body.css" />
<link rel="stylesheet" type="text/css" href="styles/admin_header.css" />
<link rel="stylesheet" type="text/css" href="styles/admin_footer.css" />
<link rel="stylesheet" type="text/css" href="styles/admin_postspace.css" />
</head>
<body>
<header>
<!--Header Info Here -->
</header>
<div class="wrapper">
<div class="sidebar">
<ul>
<li>Post New Band</li>
</ul>
</div>
<article>
<?php
if (isset($_GET['post_new_band'])){
require ("includes/post_new_band.php");
echo "Page accessed";
} else {
echo "Page not accessible.";
}
?>
</article>
</div>
</body>
</html>
I have it echo page not available when "index.php?page" doesn't exist. But when it does exist, such as "index.php?post_new_band" (code below) nothing is posted. The sever and database work, that is for sure. MySQL isn't the problem since I am trying to get the html to work.
Code for "post_new_band.php":
<!DOCTYPE html>
<html>
<head>
<!-- Head Info Goes Here -->
</head>
<body>
<h1>Insert New Band</h1>
<form action='index.php?post_new_band' method='post'>
<b>Insert New Band</b><input type='text' name='band_name' />
<b>Insert Band Origin</b><input type='text' name='band_origin' />
<input type='submit' name='insert_band' value='Add Band' />
</form>
<?php
if (isset($_POST['post_new_band'])){
$band_name = $_POST['band_name'];
if($band_name==''){
echo "<script>alert ('Please Insert Band Name')</script>";
echo "<script>window.open('index.php?post_new_band','_self')</script>"
} else {
$insert_band_name = "insert into Band (band_name) values ('$band_name')";
$run_band_name = mysql_query("$insert_band_name");
echo "<script>alert ('New Category Added')</script>";
echo "<script>window.open('index.php?post_new_band','_self')</script>"
}
}
?>
</body>
</html>
You can only use a request key once - so dont use $_GET['post_new_band'] and $_POST['post_new_band'] in the same request. Change one of the keys.
This is pretty stupid, but it actually turned out to be a syntax error involving semi-colons. *Slap to the face.

CSS stylesheets path not being detected by the server 404 not found error?

I have a Header File by the name header.php which goes like this :
It is inside a folder called includes so the path is includes/header.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html dir="ltr" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>***</title>
<link rel='stylesheet' href='../_layout/scripts/jquery.fullcalendar/fullcalendar.css' type='text/css' media='screen' />
<link rel='stylesheet' href='../_layout/scripts/jquery.fullcalendar/fullcalendar.print.css' type='text/css' media='print' />
<!-- Styles -->
<link rel='stylesheet' href='style.css' type='text/css' media='all' />
<!--[if IE]>
<link rel='stylesheet' href='../_layout/IE.css' type='text/css' media='all' />
<![endif]-->
<!-- Fonts -->
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold|PT+Sans+Narrow:regular,bold|Droid+Serif:i&v1' rel='stylesheet' type='text/css' />
<script type='text/javascript' src='../../../ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min97e1.js?ver=1.7'></script>
<!-- WYSISYG Editor -->
<script type='text/javascript' src='../_layout/scripts/nicEdit/nicEdit.js'></script>
<!-- Forms Elemets -->
<script type='text/javascript' src='../_layout/scripts/jquery.uniform/jquery.uniform.min.js'></script>
<link rel='stylesheet' href='../_layout/scripts/jquery.uniform/uniform.default.css' type='text/css' media='screen' />
<!-- Scripts -->
<script type='text/javascript' src='../_layout/custom.js'></script>
</head>
<body>
<div id="layout">
<div id="header-wrapper">
<div id="header">
<div id="user-wrapper" class="fixed">
<div class="color-scheme">
</div>
<div class='user'>
<?php
if($_SESSION['user'] != 'NULL')
{
?>
<img src="../_content/user-img.png" alt="" />
<span>Welcome Admin <?PHP echo $_SESSION['user']; ?></span>
<span class="logout">Logout</span>
<?php
}
?>
</div>
</div>
<div id="launcher-wrapper" class="fixed"><img src="../_layout/images/NGBU Logo.png" width="68" height="81" alt="logo" style="margin-left:35px;" /> <img src="../_content/NGBU_logo.png" width="777" height="57" alt="logo" longdesc="http://index.php" style="margin-top: 25px; float: left; margin-left: 25px;"/></div>
</div>
</div>
I am calling this file at the beginning of my Index.php but for some reasons its not rendering from the hosted server although it is being rendered when i was testing it under localhost?
My index.php which is inside a folder admin goes like :
<?PHP
session_start();
ob_start();
$_SESSION['user'] = "NULL";
$_SESSION['password'] = "";
$_SESSION['error'] = 0;
include_once("../includes/header.php");
if(!$_SESSION['error'])
$_SESSION['error'] = "Please Login to Continue";
?>
<?PHP
if(isset($_REQUEST['check']))
{
if(!$_REQUEST['User'] == "")
{
if(!$_REQUEST['Password'] == "")
{
$_SESSION['user'] = $_REQUEST['User'];
$_SESSION['password'] = $_REQUEST['Password'];
unset($_SESSION['error']);
header('Location: checklogin.php');
}
else
{
$_SESSION['error'] = "<FONT color='#FF0000'>Both fields are required</FONT>";
}
}
else
{
$_SESSION['error'] = "<FONT color='#FF0000'>Both fields are required</FONT>";
}
}
?>
<DIV class="page fixed">
<DIV id="sidebar" style="height:400px; width:250px; margin-left:5px;"> </DIV>
<DIV id="content">
<?PHP
echo "<h1 style='margin-left:150px;' >".$_SESSION['error']."</h1>";
?>
<FORM action="index.php" method="post" name="loginfrm" class="form-elements-inputs" style="margin-left:150px;width:90px;">
<INPUT class="normal" type="text" name="User" value="User Name" /><BR />
<INPUT class="normal" type="password" name="Password" value="Password" /><BR />
<INPUT type="hidden" name="check" value="login" />
<INPUT type="submit" value="Login" class="button-orange" style="width:100px; margin:auto;" />
</FORM>
</DIV>
</DIV>
</div>
</BODY>
</HTML>
The style.css file is sitting right next to header.php in includes folder then why it is not being applied?
While checking through firebug in mozilla its showing me this output :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<title>***</title>
<link type="text/css" href="style.css" rel="stylesheet">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /style.css was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<hr>
<address>Apache Server at www.***.com Port 80</address>
</body></html>
</link>
<link media="screen" type="text/css" href="scripts/jquery.fullcalendar/fullcalendar.css" rel="stylesheet">
<link media="print" type="text/css" href="scripts/jquery.fullcalendar/fullcalendar.print.css" rel="stylesheet">
<link media="screen" type="text/css" href="scripts/jquery.uniform/uniform.default.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Sans:regular,bold|PT+Sans+Narrow:regular,bold|Droid+Serif:i&v1">
<script src="../../../ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min97e1.js?ver=1.7" type="text/javascript">
<script src="../_layout/scripts/nicEdit/nicEdit.js" type="text/javascript">
<script src="../_layout/scripts/jquery.uniform/jquery.uniform.min.js" type="text/javascript">
<script src="../_layout/custom.js" type="text/javascript">
</head>
<body>
</html>
Why there is a 404 not found error when the path is correct?
Please help
You're including ../include/header.php and style.css is there too, namely ../include/style.css. So, you must either use the same relative path or an absolute path to your css /include/style.css.
The link to your CSS file should be relative to the URL of the page you are viewing.
For example, if you view your page at example.com, you must reference the CSS file with example.com/includes/style.css.
Maybe it's better to test with header.php absolute path first.
Also path of your scripts and style sheets should be relative to index.php not header.
(Sorry for bad English)

Categories