How to have a URL based off a username PHP - php

The question may seems vague and I apologise fully, so I'll try and explain it better here. Basically, I have 2 .php files, the index.php and php.php. On index.php a user will enter their username into the form where they would then submit the input, php.php then grabs the username (using the $_POST[] method.) and display the data on that page. The URL at this point looks like this;
http://minecraftnamespy.esy.es/php.php.
How would I do it so that the username the user types would be added onto the URL? E.g;
User inputs: _scrunch as username.
URL now changes from http://minecraftnamespy.esy.es/php.php to
http://minecraftnamespy.esy.es/php?=_scrunch
I should like to point out that I am working with the Mojang API here.
My php.php code is:
<?php
//error_reporting(E_ALL & ~E_NOTICE);
// Load the username from somewhere
if (
$username = $_POST["username"]
) {
//do nothing
} else {
$username = "notch";
}
//allow the user to change the skin
$skinChange = "<a href='https://minecraft.net/profile/skin/remote?url=http://skins.minecraft.net/MinecraftSkins/$username.png' target='_blank' </a>";
//grabbing the users information
if ($content = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . urlencode($username))
) {
$userSkin = "<img src='https://mcapi.ca/skin/3d/$username' />";
} else {
$content = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . urlencode($username) . '?at=0');
if( $http_response_header['0'] == "HTTP/1.1 204 No Content") {
echo "Not a valid Minecraft Username! <a href='index.php'><button>Search Again?</button></a>";
die;
}
$json = json_decode($content);
foreach ($json as $currentName) {
$currentName = $currentName;
}
$userSkin = "<img src='https://mcapi.ca/skin/3d/$currentName' />";
}
// Decode it
$json = json_decode($content);
// Check for error
if (!empty($json->error)) {
die('An error happened: ' . $json->errorMessage);
}
// Save the uuid
$uuid = $json->id;
// Get the history (using $json->uuid)
$content = file_get_contents('https://api.mojang.com/user/profiles/' . urlencode($uuid) . '/names');
// Decode it
$json = json_decode($content);
$names = array(); // Create a new array
foreach ($json as $name) {
$input = $name->name;
if (!empty($name->changedToAt)) {
// Convert to YYYY-MM-DD HH:MM:SS format
$time = date('Y-m-d H:i:s', $name->changedToAt);
$input .= ' (changed at ' . $time . ')';
}
$names[] = $input; // Add each "name" value to our array "names"
}
//url to users 2D head (avatar)
$usersAvatar = "https://mcapi.ca/avatar/2d/$input/55";
//user's Avatar as favivon
$usersFavicon = "<link rel='shortcut icon' href='$usersAvatar' type='image/png' />";
//use $uuid tp grab UUID of the user - ---- - - - use $names to get name history of the user.
?>
<html>
<head>
<?php echo $usersFavicon;?>
<title><?php echo $username?>'s Information</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<title>Find a player skin!</title>
<style>
body {
background-image: url(http://minecraftnamespy.esy.es/grad.jpg);
background-position: bottom;
background-repeat: no-repeat;
background-size: 100% 500px;
}
#content {
margin-left: auto;
margin-right: auto;
width: 60%;
}
img.logo {
margin-right: auto;
margin-left: auto;
display: block;
padding: 30px;
max-width: 100%;
height: auto;
width: auto\9;
}
.center {
margin-left: auto;
margin-right: auto;
}
.footer {
text-align: center;
}
p.responsive {
word-wrap: break-word;
}
</style>
</head>
<body>
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://minecraftnamespy.esy.es/source.png" alt="View Source on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png">
<!--debug -->
<?php ?>
<div id="content">
<div class="col-md-12">
<img class="logo" src="http://minecraftnamespy.esy.es/logo.png">
</div>
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $username;?>'s UUID</h3>
</div>
<div class="panel-body">
<p class="responsive"><?php echo $uuid;?></p>
</div>
</div>
</div>
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $username;?>'s Name History (Oldest to Most Recent)</h3>
</div>
<div class="panel-body">
<?php echo implode(', <br>', $names) ;?>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $username;?>'s Avatar</h3>
</div>
<div class="panel-body">
<div class="center">
<?php echo $userSkin;?>
</div>
<p><?php echo $skinChange;?>Change this skin to yours!</a></p>
</div>
</div>
</div>
<div class="col-md-12">
<div class="btn-group pull-right" role="group" aria-label="">
<button type="button" class="btn btn-default">Search another Username?</button>
</div>
</div>
<div class="footer">
<span>Created by _scrunch</span> •
<span>©2015</span> •
<span>Find me on PMC</span>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="Y8MWQB9FCUTFJ">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
</div>
</body>
</html>
Here's the form that is used to submit the username on index.php.
<form action="php.php" method="GET">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Enter username">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>

You want a GET request, which are visible in the URL in the form of http://example.com/index.php?username=_scrunch
A POST request is invisible (i.e, it does not appear in the URL) and are commonly used to send sensitive data (though a POST is not enough for data security!).
Converting your POST into a GET is a simple matter of changing from
$username = $_POST["username"]
to
$username = $_GET["username"]
You can use this, note the additional inclusion of
if (!$_GET["username"]) {
exit;
}
which causes your page to exit loading and protects against misuse of the page if username is not present.
<?php
//error_reporting(E_ALL & ~E_NOTICE);
// Load the username from somewhere
if (!$_GET["username"]) {
exit;
}
if (
$username = $_GET["username"]
) {
//do nothing
} else {
$username = "notch";
}
//allow the user to change the skin
$skinChange = "<a href='https://minecraft.net/profile/skin/remote?url=http://skins.minecraft.net/MinecraftSkins/$username.png' target='_blank' </a>";
//grabbing the users information
if ($content = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . urlencode($username))
) {
$userSkin = "<img src='https://mcapi.ca/skin/3d/$username' />";
} else {
$content = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . urlencode($username) . '?at=0');
if( $http_response_header['0'] == "HTTP/1.1 204 No Content") {
echo "Not a valid Minecraft Username! <a href='index.php'><button>Search Again?</button></a>";
die;
}
$json = json_decode($content);
foreach ($json as $currentName) {
$currentName = $currentName;
}
$userSkin = "<img src='https://mcapi.ca/skin/3d/$currentName' />";
}
// Decode it
$json = json_decode($content);
// Check for error
if (!empty($json->error)) {
die('An error happened: ' . $json->errorMessage);
}
// Save the uuid
$uuid = $json->id;
// Get the history (using $json->uuid)
$content = file_get_contents('https://api.mojang.com/user/profiles/' . urlencode($uuid) . '/names');
// Decode it
$json = json_decode($content);
$names = array(); // Create a new array
foreach ($json as $name) {
$input = $name->name;
if (!empty($name->changedToAt)) {
// Convert to YYYY-MM-DD HH:MM:SS format
$time = date('Y-m-d H:i:s', $name->changedToAt);
$input .= ' (changed at ' . $time . ')';
}
$names[] = $input; // Add each "name" value to our array "names"
}
//url to users 2D head (avatar)
$usersAvatar = "https://mcapi.ca/avatar/2d/$input/55";
//user's Avatar as favivon
$usersFavicon = "<link rel='shortcut icon' href='$usersAvatar' type='image/png' />";
//use $uuid tp grab UUID of the user - ---- - - - use $names to get name history of the user.
?>
<html>
<head>
<?php echo $usersFavicon;?>
<title><?php echo $username?>'s Information</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<title>Find a player skin!</title>
<style>
body {
background-image: url(http://minecraftnamespy.esy.es/grad.jpg);
background-position: bottom;
background-repeat: no-repeat;
background-size: 100% 500px;
}
#content {
margin-left: auto;
margin-right: auto;
width: 60%;
}
img.logo {
margin-right: auto;
margin-left: auto;
display: block;
padding: 30px;
max-width: 100%;
height: auto;
width: auto\9;
}
.center {
margin-left: auto;
margin-right: auto;
}
.footer {
text-align: center;
}
p.responsive {
word-wrap: break-word;
}
</style>
</head>
<body>
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://minecraftnamespy.esy.es/source.png" alt="View Source on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png">
<!--debug -->
<?php ?>
<div id="content">
<div class="col-md-12">
<img class="logo" src="http://minecraftnamespy.esy.es/logo.png">
</div>
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $username;?>'s UUID</h3>
</div>
<div class="panel-body">
<p class="responsive"><?php echo $uuid;?></p>
</div>
</div>
</div>
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $username;?>'s Name History (Oldest to Most Recent)</h3>
</div>
<div class="panel-body">
<?php echo implode(', <br>', $names) ;?>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $username;?>'s Avatar</h3>
</div>
<div class="panel-body">
<div class="center">
<?php echo $userSkin;?>
</div>
<p><?php echo $skinChange;?>Change this skin to yours!</a></p>
</div>
</div>
</div>
<div class="col-md-12">
<div class="btn-group pull-right" role="group" aria-label="">
<button type="button" class="btn btn-default">Search another Username?</button>
</div>
</div>
<div class="footer">
<span>Created by _scrunch</span> •
<span>©2015</span> •
<span>Find me on PMC</span>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="Y8MWQB9FCUTFJ">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
</div>
</body>
</html>

Related

CKFINDER in Ckeditor5 throws erorr

So I created a PHP on which I have added the CKEditor5 document That worked great,
After that I realised uploading images does not work. So I started digging in the documentation.
I realise I need a FileImageAdapter, instead of creating my own, I downloaded and uploaded CKfinder and the ckeditor5-ckfinder on GitHUb I uploaded both documents.
My test server is: https://webkeuken.be/
On that after login people can edit somethings, having a page like:
<?php
session_start();
if($_POST['promo'])
{
$xml=simplexml_load_file("../db.xml") or die("Error: Cannot create object");
$usernameDb = $xml->usernameDb;
$passwordDb = $xml->passwordDb;
$hostname = $xml->hostname;
$dbname = $xml->dbname;
// Create connection
$conn = new mysqli($hostname, $usernameDb, $passwordDb, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$_POST['promo']=str_replace("'", "'", $_POST['promo']);
//$sql = "INSERT INTO `product`( `naam`, `info`,`price`) VALUES (,,".."')";
$sql = "UPDATE `promo_balance` SET `promo`='".$_POST['promo']."' WHERE id=1";
if ($conn->query($sql) === TRUE) {
$_SESSION['input']= "New record created successfully";
$last = $conn->insert_id;
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
function verify()
{
if(!$_SESSION['user'])
{
if($_POST)
{
if($_POST['user']=="l-admin" && $_POST['pass']=="balance2016")
{
$_SESSION['user']="ok";
}
else
{
echo '
<form method="post" class="text-left" style="margin-top: 2%;">
<label style="margin-top: 2%;">USER</label>
<input type="text" name="user" class="form-control"/>
<label style="margin-top: 2%;">PASSWORD</label>
<input type="password" name="pass" class="form-control"/>
<input type="submit" class="form-control" style="margin-top: 2%;"/>
<span>Foute login gegevens</span>
</form>
';
}
}
else
{
echo '
<form method="post" class="text-left" style="margin-top: 2%;">
<label style="margin-top: 2%;">USER</label>
<input type="text" name="user" class="form-control"/>
<label style="margin-top: 2%;">PASSWORD</label>
<input type="password" name="pass" class="form-control"/>
<input type="submit" class="form-control" style="margin-top: 2%;"/>
</form>
';
}
}
}
function getPromo()
{
$xml=simplexml_load_file("../db.xml") or die("Error: Cannot create object");
$usernameDb = $xml->usernameDb;
$passwordDb = $xml->passwordDb;
$hostname = $xml->hostname;
$dbname = $xml->dbname;
$rij = array();
// Create connection
$conn = new mysqli($hostname, $usernameDb, $passwordDb, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT promo FROM promo_balance where id=1";
$item='';
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$item = $row['promo'];
}
} else {
echo "0 results";
}
$conn->close();
return $item;
}
function toonForm(){
echo "<div class='col-lg-6'>";
echo "<h3><i class='fa fa-info'></i> Je kan hier een tekst schrijven, deze past zich aan.</h3>";
echo "<h3><i class='fa fa-bullhorn'></i> Ideaal voor je promoties.</h3>";
echo '<form method="post">';
echo '<label>Pas hier uw tekst aan</label>';
echo '
<div id="toolbar-container"></div>
<div id="editor">
'.getPromo().'
</div>
';
echo "<h5><i class='fa fa-pencil'></i> Deze tool werkt met Word Live</h5>";
echo '<input type="submit" class="btn btn-info btn-block" />';
echo '</form>';
}
function showOptions()
{
echo '<div class="row text-center">
<div class="col-lg-8 col-lg-offset-4">
<h2>Beheer uw promo vak</h2>
</div></div>';
echo '<div class="row">';
echo '<div class="col-lg-4">';
echo '
<script type="text/javascript">
google_ad_client = "ca-pub-3598185186227907";
google_ad_slot = "4603323478";
google_ad_width = 300;
google_ad_height = 250;
</script>
<!-- Extra -->
<script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
echo '</div>';
echo '<div class="col-lg-2 col-lg-offset-2 text-center ">';
echo '<div class="thumbnail">';
echo '<div class="caption">
<h1><i class="fa fa-arrow-left"></i></h1>
<h3>GA TERUG</h3>
<p> VORIG</p>
</div>';
echo '</div>';
echo '</div>';
echo '</div>';
//END OF ROW 1
echo '<div class="row">';
echo '<div class="col-lg-4">';
echo '<script type="text/javascript">
google_ad_client = "ca-pub-3598185186227907";
google_ad_slot = "4603323478";
google_ad_width = 300;
google_ad_height = 250;
</script>
<!-- Extra -->
<script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
echo '</div>';
toonForm();
echo '</div>';
echo "</div>";
//END ROW 2
echo '<div class="row">';
echo '<div class="col-lg-4">';
echo '
<script type="text/javascript">
google_ad_client = "ca-pub-3598185186227907";
google_ad_slot = "4603323478";
google_ad_width = 300;
google_ad_height = 250;
</script>
<!-- Extra -->
<script type="text/javascript"
src="//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
echo '</div>';
echo '</div>';// END ROW 3
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Krijtbord | Pas uw website aan in één klik.</title>
<meta name="description" content="Krijtbord | Pas uw website aan in één klik." />
<meta name="google-site-verification" content="ExQ89lGiGlXTIDoWcfx5CxMkRu-Wtubn8FYir2BJRU8" />
<link href="/bootstrap-assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Style -->
<link href="/plugins/owl-carousel/owl.carousel.css" rel="stylesheet">
<link href="/plugins/owl-carousel/owl.theme.css" rel="stylesheet">
<link href="/plugins/owl-carousel/owl.transitions.css" rel="stylesheet">
<link href="/plugins/Lightbox/dist/css/lightbox.css" rel="stylesheet">
<link href="/plugins/Icons/et-line-font/style.css" rel="stylesheet">
<link href="/plugins/animate.css/animate.css" rel="stylesheet">
<link rel="stylesheet" href="/plugins/font-awesome-4.7.0/css/font-awesome.min.css">
<link href="/css/main.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid ruimte-top">
<div id="vliegerContent" style="padding-top: 4%; padding-bottom: 4%; border-bottom: 1px solid black;background: url('/tegels/bg.jpg'); background-size: cover;" class="text-center">
<h1 style=" width: 100%; text-shadow: 3px 3px #000; color: white; margin-top: 0; margin-left: auto; margin-right: auto; padding-top: 5%; padding-bottom: 5%;"class="text-vertical-center" data-stellar-background-ratio="0.5">Beheerders Pagina</h1>
</div>
<?php verify();?>
<div class="row" style="padding-bottom: 1%; background-color: white;">
</div>
<?php
if($_SESSION['user']=="ok")
{
showOptions();
}
?>
<div class="row" style="border-top: 1px solid black; margin-right: 0; margin-left: 0;">
<div class="text-center ruimte-top">
</div>
</div>
<div class="row ruimte-bottom" style=" margin-right: 0; margin-left: 0;">
<div class="col-lg-4 col-md-4 col-sm-4 col-lg-offset-2 col-md-offset-2 col-sm-offset-2">
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/"><img
alt="Creative Commons License" style="border-width:0"
src="https://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png"/></a><a rel="license"
href="http://creativecommons.org/licenses/by-nc-nd/3.0/"></a>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-lg-offset-2 col-md-offset-2 col-sm-offset-2">
<a rel="license" href="http://cogitatio.be" id="support">Met de steun van Cogitatio.be</a>
</div>
</div>
</div>
<!-- JS SCRIPTS -->
<script src="https://cdn.ckeditor.com/ckeditor5/15.0.0/decoupled-document/ckeditor.js"></script>
<script src="https://code.jquery.com/jquery-2.2.0.min.js" type="text/javascript"></script>
<script src="/js/modernizr.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="behaviour.js"></script>
<script>
$( "#verstuur" ).prop( "disabled", true );
$("#goed").hide();
function IsEmail()
{
var regex = /^([a-zA-Z0-9_.+-])+\#(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(regex.test(document.getElementById('email').value))
{
$( "#verstuur" ).prop( "disabled", false );
$("#goed").show();
$("#fout").hide();
}
else
{
$("#goed").hide();
$("#fout").show();
}
}
</script>
<script>
import CKFinder from '#ckeditor/ckeditor5-ckfinder/src/ckfinder';
DecoupledEditor
.create( document.querySelector( '#editor' ), {
plugins: [ CKFinder, ... ],
// Enable the "Insert image" button in the toolbar.
// toolbar: [ 'imageUpload', ... ],
ckfinder: {
// Upload the images to the server using the CKFinder QuickUpload command.
uploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json'
} )
.then( editor => {
const toolbarContainer = document.querySelector( '#toolbar-container' );
toolbarContainer.appendChild( editor.ui.view.toolbar.element );
} )
.catch( error => {
console.error( error );
} );
</script>
</body>
</html>
Now my page just renders the getPromo Content,
In my console I get:
Uncaught SyntaxError: Cannot use import statement outside a module
For those who need a CkFinder and CkEditor in there site.
The Setup is quite different as I thought. (Took me a lot of time).
CkEditor setup is quite easy. The CKFinder is ok. But on the docs they do an import. With:
import CKFinder from '#ckeditor/ckeditor5-ckfinder/src/ckfinder';
This caused an error.
Working Script for Upload
<script>
DecoupledEditor
.create( document.querySelector( '#editor' ), {
ckfinder: {
// Upload the images to the server using the CKFinder QuickUpload command.
uploadUrl: 'https://www.yumyumsushi.be/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json'
}
} )
.then( editor => {
const toolbarContainer = document.querySelector( '#toolbar-container' );
toolbarContainer.appendChild( editor.ui.view.toolbar.element );
} )
.catch( error => {
console.error( error );
} );
</script>

Firebase Cloud Messaging using PHP

I'm trying to use PHP to send a notification from my localhost server. But I cannot get it to work. I previously received curl error. I solved it. But now it doesn't yield any errors. I can successfully send notifications from the Firebase console.
I have created FirebaseCloudMessaging.php to send the messages using curl.
<?php
/**
* Created by PhpStorm.
* User: Isuru
* Date: 18/11/2016
* Time: 16:47
*/
class FirebaseCloudMessaging {
// this methods send messages to a single device
public function send($to, $message){
$fields = array(
'to' => $to,
'data' => $message,
);
return $this->sendPushNotification($fields);
}
// Send message to topic subscribers
public function sendToTopic($to, $message){
$fields = array(
'to' => '/topics/'. $to,
'data' => $message,
);
return $this->sendPushNotification($fields);
}
// Send push message to multiple devices
public function sendToMultipleDevices($registrationIds, $message){
$fields = array(
'to' => $registrationIds,
'data' => $message,
);
return $this->sendPushNotification($fields);
}
// CURL request to Firebase Platform
private function sendPushNotification($fields){
require_once __DIR__ . '/config.php';
// POST variables
$url = 'https://fcm.googleapis.com/fcm/send';
$headers = array(
'Authorization: key=' . FIREBASE_API_KEY,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the URL, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
// Disable SSL Certificate Support temporary
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}else{
json_decode($result);
}
// Close connection
curl_close($ch);
return $result;
}
}
And PushNotification.php is a model class for the messages.
<?php
/**
* Created by PhpStorm.
* User: Isuru
* Date: 17/11/2016
* Time: 01:32
*/
class PushNotification{
// push message title, message and image
private $title;
private $message;
private $image;
// data payload
private $data;
// flag indicating whether to
// show the push notification
private $is_background;
function _construct(){
}
public function setTitle($title){
$this->title = $title;
}
public function setMessage($message){
$this->message = $message;
}
public function setImage($imageUrl){
$this->image = $imageUrl;
}
public function setDataPayload($data){
$this->data = $data;
}
public function setIsBackground($is_background){
$this->is_background = $is_background;
}
public function getPushNotification(){
$res = array();
$res['data']['title'] = $this->title;
$res['data']['is_background'] = $this->is_background;
$res['data']['message'] = $this->message;
$res['data']['image'] = $this->image;
$res['data']['payload'] = $this->data;
$res['data']['timestamp'] = date('Y-m-d G:i:s');
return $res;
}
}
Following index.php shows the form and process the form submission.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Firebase Cloud Messaging</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
/*Panel tabs*/
.panel-tabs {
position: relative;
bottom: 30px;
clear: both;
border-bottom: 1px solid transparent;
}
.panel-tabs > li {
float: left;
margin-bottom: -1px;
}
.panel-tabs > li > a {
margin-right: 2px;
margin-top: 4px;
line-height: .85;
border: 1px solid transparent;
border-radius: 4px 4px 0 0;
color: #ffffff;
}
.panel-tabs > li > a:hover {
border-color: transparent;
color: #ffffff;
background-color: transparent;
}
.panel-tabs > li.active > a,
.panel-tabs > li.active > a:hover,
.panel-tabs > li.active > a:focus {
color: #fff;
cursor: default;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
background-color: rgba(255, 255, 255, .23);
border-bottom-color: transparent;
}
.input_width {
width: 520px;
}
</style>
</head>
<body>
<br>
<div class="container">
<?php
// Enabling error reporting
error_reporting(-1);
ini_set('display_errors', 'On');
require_once __DIR__ . '/FirebaseCloudMessaging.php';
require_once __DIR__ . '/PushNotification.php';
$firebaseCloudMessaging = new FirebaseCloudMessaging();
$pushNotification = new PushNotification();
// optional payload
$payload = array();
// notification title
$title = isset($_GET['title']) ? $_GET['title'] : '';
// notification message
$message = isset($_GET['message']) ? $_GET['message'] : '';
// push type - single user / topic
$push_type = isset($_GET['push_type']) ? $_GET['push_type'] : '';
$pushNotification->setTitle($title);
$pushNotification->setMessage($message);
$pushNotification->setIsBackground(FALSE);
$pushNotification->setDataPayload($payload);
$json = '';
$response = '';
if ($push_type == 'topic') {
$json = $pushNotification->getPushNotification();
$response = $firebaseCloudMessaging->sendToTopic('news', $json);
} else if ($push_type == 'individual') {
$json = $pushNotification->getPushNotification();
$regId = isset($_GET['regId']) ? $_GET['regId'] : '';
$response = $firebaseCloudMessaging->send($regId, $json);
}
?>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-primary">
<div class="fl_window">
<br/>
<?php if ($json != '') { ?>
<label><b>Request:</b></label>
<div class="json_preview">
<pre><?php echo json_encode($json) ?></pre>
</div>
<?php } ?>
<br/>
<?php if ($response != '') { ?>
<label><b>Response:</b></label>
<div class="json_preview">
<pre><?php echo json_encode($response) ?></pre>
</div>
<?php } ?>
</div>
<div class="panel-heading">
<h3 class="panel-title">Firebase Cloud Messaging</h3>
<span class="pull-right">
<!-- Tabs -->
<ul class="nav panel-tabs">
<li class="active">Single Device</li>
<li>Send To Topic 'News'</li>
</ul>
</span>
</div>
<div class="panel-body">
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<form class="pure-form pure-form-stacked" method="get">
<fieldset>
<div class="form-group">
<div class="input_width">
<input
class="form-control input-lg" type="text"
placeholder="Enter Firebase Registration ID" id="redId" name="regId"
placeholder="Enter Firebase Registration ID">
</div>
</div>
<div class="form-group">
<div class="input_width">
<input
class="form-control input-lg" type="title"
placeholder="Enter Title" id="title" name="title">
</div>
</div>
<div class="form-group">
<div>
<textarea class="input_width input-lg" rows="5" name="message" id="message"
placeholder="Notification message!"></textarea>
</div>
</div>
<div class="form-group">
<div>
<input name="include_image" id="include_image" type="checkbox"> Include
image
</div>
</div>
</fieldset>
<input type="hidden" name="push_type" value="individual"/>
<div class=" text-center">
<input type="submit" class="btn btn-primary" value="SUBMIT"/>
</div>
</form>
</div>
<div class="tab-pane" id="tab2">
<form class="pure-form pure-form-stacked" method="get">
<fieldset>
<div class="form-group">
<div class="input_width">
<input
class="form-control input-lg" type="text"
placeholder="Enter Title" id="title1" name="title"
placeholder="Enter Title">
</div>
</div>
<div class="form-group">
<div>
<textarea class="input_width input-lg" rows="5" name="message" id="message"
placeholder="Notification message!"></textarea>
</div>
</div>
<div class="form-group">
<div>
<input name="include_image" id="include_image" type="checkbox"> Include
image
</div>
</div>
</fieldset>
<input type="hidden" name="push_type" value="topic"/>
<div class=" text-center">
<input type="submit" class="btn btn-primary" value="Send to Topic Subscribers"/>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</html>
And config.php stores the web API. Is there a way to debug the code? For example to check whether Google accepts my request? Any suggestion is appreciated.
Thank you!
Change your $fields array like this
$fields = array (
'registration_ids' => array (
$registrationIds
),
'notification' => array (
"title" => "Title here",
"text" => $message
));
It's work for me

PHP: Images file is not uploading on the server?

When I upload file on my localhost it works fine. But when I upload it on the server it doesn't work. Image is displaying on that page correctly from same directory but it has problem in uploading file to that directory.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Belvic Print - Home page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes"/>
<meta name="description" content="Printing template">
<meta name="author" content="Netbase">
<!--Add css lib-->
<link href='http://fonts.googleapis.com/css?family=Roboto:500,300,700,400' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Arimo:500,300,700,400' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:500,300,700,400' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="bootstrap-3.3.6-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="bootstrap-3.3.6-dist/font-awesome-4.5.0/css/font-awesome.css">
<link rel="stylesheet" href="sidebar.css">
<script src="bootstrap-3.3.6-dist/js/jquery-1.12.2.min.js"></script>
<script src="bootstrap-3.3.6-dist/js/bootstrap.min.js"></script>
<script src="code_adimn.js"></script>
<script src="script.js"></script>
<style>
body{
position: relative;
overflow-x: hidden;
}
.main-container{
margin:0;
padding:0;
}
.submit_button{
border: none;
margin-top: 5%;
padding: 10px;
}
label.myLabel input[type="file"] {
position: fixed;
top: -1000px;
}
.col-lg-offset-4{
margin-bottom: 5%;
}
.row{
margin-top: 3%;
}
/***** Example custom styling *****/
.myLabel {
/*border: 2px solid #AAA;*/
padding: 10px;
margin-top: 5%;
background: #DDD;
display: inline-block;
}
.myLabel:hover {
background: #CCC;
}
.myLabel:active {
background: #CCF;
}
.myLabel :invalid + span {
color: #A44;
}
.myLabel :valid + span {
color: #4A4;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<div class="navibar">
<div class="fa fa-bars"> <span> Menu Bar </span></div>
<ul>
<div class="fa fa-close"></div>
<h2 class="admin">Admin Panel</h2>
<li>Image 1</li>
<li>Image 2</li>
<li>Image 3</li>
</ul>
</div>
<div class="row img-row">
<div id="first" class="rows col-lg-6 col-sm-10 col-sm-offset-1 col-xs-10 col-xs-offset-1 col-lg-offset-4">
<?php
include("db.php");
$res = mysqli_query($conn, "SELECT * FROM image WHERE id=1");
while ($record = mysqli_fetch_array($res)) {
?>
<img src="<?php echo "../images/slider/home/" . $record['image1']; ?>" alt="" width="100%">//This image is displaying correctly from same directory
<form enctype="multipart/form-data" action="slider.php" method="POST" >
<label class="myLabel">
<input type="file" name="myfile1"/>
<span>Change Picture</span>
</label>
<input name="submit1" type="submit" class="submit_button">
<div class="clearfix"></div>
</form>
<form action="slider.php" method="POST" enctype="multipart/form-data">
<label name="description">Enter the heading: </label>
<input type="text" name="heading1" class="form-control" placeholder="Enter the heading" value="<?php echo $record['image2']; ?>">
<br>
<label name="description">Enter the Description</label>
<textarea name="description1" class="form-control" rows="3"><?php echo $record['image3'];} ?></textarea>
<input name="submit_content1" type="submit" class="pull-left submit_button">
</form>
</div>
<div id="second" class="rows col-lg-6 col-sm-10 col-sm-offset-1 col-xs-10 col-xs-offset-1 col-lg-offset-4">
<?php
$res1 = mysqli_query($conn, "SELECT * FROM image WHERE id=1");
while ($record1 = mysqli_fetch_array($res1)) {
?>
<img src="<?php echo "../images/slider/home/" . $record1['image4']; ?>" alt="kk" width="100%">
<form action="slider.php" method="POST" enctype="multipart/form-data">
<label class="myLabel">
<input type="file" name="myfile2"/>
<span>Upload Picture</span>
</label>
<input name="submit2" type="submit" class="submit_button">
<div class="clearfix"></div>
</form>
<form action="slider.php" method="POST" enctype="multipart/form-data">
<label name="description">Enter the heading: </label>
<input type="text" name="heading2" class="form-control" placeholder="Enter the heading" value="<?php echo $record1['image5']; ?>">
<br>
<label name="description">Enter the Description</label>
<textarea name="description2" class="form-control" rows="3"><?php echo $record1['image6'];} ?></textarea>
<input name="submit_content2" type="submit" class="pull-left submit_button">
</form>
</div>
<div id="third" class="rows col-lg-6 col-sm-10 col-sm-offset-1 col-xs-10 col-xs-offset-1 col-lg-offset-4">
<?php
$res2 = mysqli_query($conn, "SELECT * FROM image WHERE id=1");
while ($record2 = mysqli_fetch_array($res2)) {
?>
<img src="<?php echo "../images/slider/home/" . $record2['image7']; ?>" alt="" width="100%">
<form action="slider.php" method="POST" enctype="multipart/form-data">
<label class="myLabel">
<input type="file" name="myfile3"/>
<span>Upload Picture</span>
</label>
<input name="submit3" type="submit" class="submit_button">
<div class="clearfix"></div>
</form>
<form action="slider.php" method="POST" enctype="multipart/form-data">
<label name="description">Enter the heading: </label>
<input type="text" name="heading3" class="form-control" placeholder="Enter the heading" value="<?php echo $record2['image8']; ?>">
<br>
<label name="description">Enter the Description</label>
<textarea name="description3" class="form-control" rows="3"><?php echo $record2['image9'];} ?></textarea>
<input name="submit_content3" type="submit" class="pull-left submit_button">
</form>
</div>
</div>
</div>
<?php
if (isset($_POST['submit1'])) {
$type = $_FILES["myfile1"]["type"];
$size = $_FILES["myfile1"]["size"];
$temp = $_FILES["myfile1"]["tmp_name"];
$error = $_FILES["myfile1"]["error"];
if ($_FILES["myfile1"]["error"] < 1) {
if (exif_imagetype($_FILES["myfile1"]["tmp_name"]) != IMAGETYPE_PNG && exif_imagetype($_FILES["myfile1"]["tmp_name"]) != IMAGETYPE_JPEG
&& exif_imagetype($_FILES["myfile1"]["tmp_name"]) != IMAGETYPE_GIF && exif_imagetype($_FILES["myfile1"]["tmp_name"]) != IMAGETYPE_ICO) {
echo 'There is problem with image file or file is not image';
} else {
$name = "image_" . date('Y-m-d-H-i-s') . '_' . uniqid() . '.jpg';
$upload = move_uploaded_file($temp, "../images/slider/home/" . $name);
if ($_FILES["myfile1"]["error"] > 0) {
echo "Some error in file upload";
} else {
$sql = "UPDATE image SET image1='$name' WHERE id=1";
if (mysqli_query($conn, $sql) && $upload) {
echo "Refresh the page to see the effect";
} else {
echo "Some error while updating image";
}
}
}
}
else {
echo "There is error in image file";
}
}
//For image 2
if (isset($_POST['submit2'])) {
$type = $_FILES["myfile2"]["type"];
$size = $_FILES["myfile2"]["size"];
$temp = $_FILES["myfile2"]["tmp_name"];
$error = $_FILES["myfile2"]["error"];
if ($_FILES["myfile2"]["error"] < 1) {
if (exif_imagetype($_FILES["myfile2"]["tmp_name"]) != IMAGETYPE_PNG && exif_imagetype($_FILES["myfile2"]["tmp_name"]) != IMAGETYPE_JPEG
&& exif_imagetype($_FILES["myfile2"]["tmp_name"]) != IMAGETYPE_GIF && exif_imagetype($_FILES["myfile2"]["tmp_name"]) != IMAGETYPE_ICO) {
echo 'There is problem with image file or file is not image';
} else {
$name = "image_" . date('Y-m-d-H-i-s') . '_' . uniqid() . '.jpg';
$upload = move_uploaded_file($temp, "../images/slider/home/" . $name);
if ($_FILES["myfile2"]["error"] > 0) {
echo "Some error in file upload";
} else {
$sql = "UPDATE image SET image4='$name' WHERE id=1";
if (mysqli_query($conn, $sql) && $upload) {
echo "Refresh the page to see the effect";
} else {
echo "Some error while updating image";
}
}
}
}
else {
echo "There is error in image file";
}
}
//For image 3
if (isset($_POST['submit3'])) {
$type = $_FILES["myfile3"]["type"];
$size = $_FILES["myfile3"]["size"];
$temp = $_FILES["myfile3"]["tmp_name"];
$error = $_FILES["myfile3"]["error"];
if ($_FILES["myfile3"]["error"] < 1) {
if (exif_imagetype($_FILES["myfile3"]["tmp_name"]) != IMAGETYPE_PNG && exif_imagetype($_FILES["myfile3"]["tmp_name"]) != IMAGETYPE_JPEG
&& exif_imagetype($_FILES["myfile3"]["tmp_name"]) != IMAGETYPE_GIF && exif_imagetype($_FILES["myfile3"]["tmp_name"]) != IMAGETYPE_ICO) {
echo 'There is problem with image file or file is not image';
} else {
$name = "image_" . date('Y-m-d-H-i-s') . '_' . uniqid() . '.jpg';
$upload = move_uploaded_file($temp, "../images/slider/home/" . $name);
if ($_FILES["myfile3"]["error"] > 0) {
echo "Some error in file upload";
} else {
$sql = "UPDATE image SET image7='$name' WHERE id=1";
if (mysqli_query($conn, $sql) && $upload) {
echo "Refresh the page to see the effect";
} else {
echo "Some error while updating image";
}
}
}
}
else {
echo "There is error in image file";
}
}
//For content 1
if (isset($_POST['submit_content1'])) {
$heading1 = $_POST['heading1'];
$description1 = $_POST['description1'];
$update1 = "UPDATE image SET image2='$heading1', image3='$description1' WHERE id=1";
if (mysqli_query($conn, $update1)) {
echo "";
} else {
echo mysqli_error($conn);
}
}
//For content 2
if (isset($_POST['submit_content2'])) {
$heading2 = $_POST['heading2'];
$description2 = $_POST['description2'];
$update2 = "UPDATE image SET image5='$heading2', image6='$description2' WHERE id=1";
if (mysqli_query($conn, $update2)) {
echo "";
} else {
echo mysqli_error($conn);
}
}
//For content 3
if (isset($_POST['submit_content3'])) {
$heading3 = $_POST['heading3'];
$description3 = $_POST['description3'];
$update3 = "UPDATE image SET image8='$heading3', image6='$description3' WHERE id=1";
if (mysqli_query($conn, $update3)) {
echo "";
} else {
echo mysqli_error($conn);
}
}
?>
</body>
add this 2 lines on php.ini (or unquote it)
extension=php_mbstring.dll
extension=php_exif.dll
and like i said use is_uploaded_file before moving files :)

How do you implement post-get-direct with a php login?

Is post-redirect-get a new thing because there is not a lot of info on it that I could understand anyway...
My code is your basic php password script..
<?php
//put sha1() encrypted password here - example is 'hello'
$password = 'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d';
session_start();
if (!isset($_SESSION['loggedIn'])) {
$_SESSION['loggedIn'] = false;
}
if (isset($_POST['password'])) {
if (sha1($_POST['password']) == $password) {
$_SESSION['loggedIn'] = true;
} else {
die ('Incorrect password');
}
}
if (!$_SESSION['loggedIn']): ?>
<html><head><title>Login</title>
<link href="mainstyle.css" rel="stylesheet" type="text/css" title="1">
<style>
#formenclosure {
width: 300px;
height:300px;
margin-top:50px;
margin-left:auto;
margin-right:auto;
color:fff;
}</style>
</head>
<div id="header">
<div id="logo">
<img src="images/zlogo1.png" width="36" height="42"
title=<?php echo '"' . $_SERVER['HTTP_USER_AGENT'] .'"' ?>"
>
</div>
<div id="enterprise">Palladium Z1 <span style="color:gold">&nbsp<?php echo $host ?></span></div> <p id='hmsg'></p>
</div>
<?php
// Check the browser level and warn users if it looks wrong (not chrome or FF or too old an FF)
// swap the beginning comments between the next two IF statements to see how the message looks.
if (strpos($_SERVER['HTTP_USER_AGENT'],'Firefox/3.')>0
||( strpos($_SERVER['HTTP_USER_AGENT'],'Firefox')==0
&& strpos($_SERVER['HTTP_USER_AGENT'],'Chrome' )==0
)
) {
// if (strpos($_SERVER['HTTP_USER_AGENT'],'Firefox/4')>0) { /* for testing */
// echo " Unsupported Browser:" . $_SERVER['HTTP_USER_AGENT'] . "\n\n";
echo " Page best viewed with Chrome or Firefox (38.5 or later).";
}
?>
</div>
<body>
<div id="formenclosure">
<fieldset>
<legend>You need to login</legend>
<form method="post">
Password: <input type="password" name="password"> <br />
<input type="submit" name="submit" value="Login">
</form>
</fieldset>
</div>
<div id="footer">
<div id='cadencelogo' title='Versions: <?php echo $verall ?>' >
<img src="images/logocadence.jpg" width="160" height="36">
</div>
</div>
</body>
</html>
<?php
exit();
endif;
?>
I've tried different methods but this seems to be the exact method I need but instead of a command it's more like a proceedure. Can anyone help?
Just add header("Location: ".$_SERVER["PHP_SELF"]); after $_SESSION['loggedIn'] = true;

Cannot modify Header Information - headers already sent

I have encountering a problem..
It outputted an error : Cannot modify header information..
What would be the cause? And how could i fix it..
Thanks for the help.. I've check all, but then still I cannot fix it. What would be the problem?
Here is my code below:
<!DOCTYPE html>
<html dir="ltr" lang="en-US"><head><!-- Created by Artisteer v4.3.0.60747 -->
<meta charset="utf-8">
<title>Home</title>
<meta name="viewport" content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">
<link rel="stylesheet" href="style.css" media="screen">
<link rel="stylesheet" href="style.responsive.css" media="all">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Salsa|PT+Sans&subset=latin">
<script src="jquery.js"></script>
<script src="script.js"></script>
<script src="script.responsive.js"></script>
<script>jQuery(function ($) {
'use strict';
if ($.fn.themeSlider) {
$(".art-slidecontainera65d557e889141cb8638b82feda1c335").each(function () {
var slideContainer = $(this), tmp;
var inner = $(".art-slider-inner", slideContainer);
inner.children().filter("script").remove();
var helper = null;
if ($.support.themeTransition) {
helper = new BackgroundHelper();
helper.init("fade", "next", $(".art-slide-item", inner).first().css($.support.themeTransition.prefix + "transition-duration"));
inner.children().each(function () {
helper.processSlide($(this));
});
} else if (browser.ie && browser.version <= 8) {
var slidesInfo = {
".art-slidea65d557e889141cb8638b82feda1c3350": {
"bgimage" : "url('images/slidea65d557e889141cb8638b82feda1c3350.jpg')",
"bgposition": "0 0",
"images": "",
"positions": ""
},
".art-slidea65d557e889141cb8638b82feda1c3351": {
"bgimage" : "url('images/slidea65d557e889141cb8638b82feda1c3351.jpg')",
"bgposition": "0 0",
"images": "",
"positions": ""
}
};
$.each(slidesInfo, function(selector, info) {
processElementMultiplyBg(slideContainer.find(selector), info);
});
}
inner.children().eq(0).addClass("active");
slideContainer.themeSlider({
pause: 2600,
speed: 600,
repeat: true,
animation: "fade",
direction: "next",
navigator: slideContainer.siblings(".art-slidenavigatora65d557e889141cb8638b82feda1c335"),
helper: helper
});
});
}
});
</script></head>
<body>
<div id="art-main">
<header class="art-header">
<div class="art-shapes">
</div>
<h1 class="art-headline">
FPES
</h1>
<h2 class="art-slogan">Faculty Performance Evaluation System.</h2>
<?php
//connect to the database
$connect = mysql_connect("localhost","root","");
mysql_select_db("db_fpes",$connect); //select the table
if(isset($_POST['btn_submit'])){
$username = $_POST['username'];
$password = $_POST['pass'];
$result = mysql_query ("SELECT * FROM professors where fac_stat = 1 and Faculty_code = '".$username."' and Faculty_code = '".$password."' ");
if($username == 'admin' && $password == 'admin' && mysql_num_rows($result) == 0 ){
header('Location: admin/home.php'); die;
}
else
{
$row = mysql_fetch_assoc($result);
if($row['system_user'] == 1){
header('Location: Grading/index.php'); die;
}
else if($row['system_user'] == 2){
header('Location: Secretary/home.php'); die;
}
else
header('Location: index.php'); die;
}
}
?>
<nav class="art-nav">
<ul class="art-hmenu"><li>Home</li>
<li>About Us</li>
</ul>
</nav>
</header>
<div class="art-sheet clearfix">
<div class="art-layout-wrapper">
<div class="art-content-layout">
<div class="art-content-layout-row">
<div class="art-layout-cell art-content"><article class="art-post art-article">
<div class="art-postcontent art-postcontent-0 clearfix"><div class="art-content-layout-wrapper layout-item-0">
<div class="art-content-layout layout-item-1">
<div class="art-content-layout-row">
<div class="art-layout-cell layout-item-2" style="width: 100%" >
<p></p><div id="a65d557e889141cb8638b82feda1c335" style="position: relative; display: inline-block; z-index: 0; margin: 0px; border-width: 0px; " class="art-collage">
<div class="art-slider art-slidecontainera65d557e889141cb8638b82feda1c335" data-width="900" data-height="287">
<div class="art-slider-inner">
<div class="art-slide-item art-slidea65d557e889141cb8638b82feda1c3350" >
</div>
<div class="art-slide-item art-slidea65d557e889141cb8638b82feda1c3351" >
</div>
</div>
</div>
<div class="art-slidenavigator art-slidenavigatora65d557e889141cb8638b82feda1c335" data-left="1" data-top="1">
</div>
</div>
<p>
</p><p>
</p>
</div>
</div>
</div>
</div>
<div class="art-content-layout layout-item-1">
<div class="art-content-layout-row">
<div class="art-layout-cell layout-item-3" style="width: 67%" >
<h2><span style="color: rgb(128, 0, 0); line-height: 51px; font-size: 40px;">Welcome&nbsp</span><span style="color: rgb(108, 127, 147); line-height: 31px; font-size: 28px;">to our site!</span></h2>
<h3><img width="250" height="195" alt="" src="images/1037312_small500.jpg" style="float: left; margin-right: 15px;" class="">Performance Faculty Evalutaion System. </h3>
<p>Insert Description Here!.<br></p>
</div>
<div class="art-layout-cell layout-item-4" style="width: 33%" >
<form method = "post" action = "">
<h1>Please Login<br></h1><p style="margin-top: 10px;"> Username: <input type="text" name = "username" > </p><p>
<p> Password: <input type="text" name = "pass"></p><p style="text-align: right;">
<input type = "submit" name = "btn_submit" class="art-button" value = "Login"/><br></p>
</form>
</div>
</div>
</div>
</article></div>
</div>
</div>
</div>
</div>
<footer class="art-footer">
<div class="art-footer-inner">
<p>GoMiracles © 2014 - 2015. All Rights Reserved.<br></p>
</div>
</footer>
</div>
</body></html>
Headers already sent is an issue where you try to redirect an user with header() or when you try to start a session session_start() when the browser already rendered content (for example html, but can also be a PHP echo statement for example).
To fix the issue, check if you have any echo() statements or raw HTML before sending headers, and check if you do not have whitespaces in front of <?php.
A more detailed answer to help you fix this issue can be found here: https://stackoverflow.com/a/8028987/4274852
I suspect you did not provide us with all your code, as I cannot find any specific problems in yours at the moment. I hope the link above helps you to debug your code, if not: Make sure to post everything above your PHP code.
Just a note: I see you are still using mysql_query statements, which are deprecated. Use msqli or PDO instead.
Edit
I see you posted your code, try replacing all your PHP code at the top of your page instead of in the middle and it should work. In your current code, you have raw HTML before the PHP code (<h1> and <p> elements in this case), which makes it impossible to send more header data using header(), as all headers were already sent before rendering the page.
I editted your code to fix the issue hopefully, you can find it here (instead of posting it here, which would make an awkward long answer):
http://pastebin.com/0JfBdjU5

Categories