How to integrate Thread and <il> - php

want to know how to combine threads to sections. When I write a new topic Published on the home and the selected partition how add to Section [ID], e.g.
www.site.com/[Section[id]/[post[ID]
Add_post.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add New Post</title>
<style type="text/css">body{background-color: grey}
.border{
border: 5px solid blue;
border-width:30px ;
}</style>
</head>
<?php
require_once("../clude/conn.php"); //Calls in the previous file we created
// form not yet submitted
// display initial form
if (!$submit)
{
?>
<center>
<div class="border" style=" direction:rtl;margin-right:10px;">
<h1 style="color: red;">Add New Post</h1>
<br>
<form action="<? echo $PHP_SELF; ?>" method="POST">
<input type="hidden" name="id" value="id">
<h4 style="color: aqua">Title</h4>
<input style="border-radius: 5px;color: red;" size="50" maxlength="60" type="text" name="title"><br />
<h4 style="color: aqua">Content</h4>
<textarea style="width: 60%; height: 400px" name="content" cols="38" rows="10"></textarea> <br />
<h4 style="color: aqua">Author</h4>
<input style="border-radius: 5px;color: red;" size="50" maxlength="250" type="text" name="author"> <br />
<br /> <input style="border: 2px dashed deepskyblue" type="Submit" name="submit" value="Add">
</form>
</div>
</center>
<?
} else {
//set up error array
$err = array();
$count = 0;
//validate the user text input fields
if (!$title) { $err[$count] = "Invalid entry: title"; $count++; }
if (!$content) { $err[$count] = "Invalid entry: content"; $count++; }
if (!$author) { $err[$count] = "Invalid entry: author"; $count++; }
// if no error found...
if (sizeof($err) == 0) {
// generate and execute query to insert the post
$query = "INSERT INTO exploit(id,title, content, author, date) VALUES(0,'$title', '$content', '$author', NOW())";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// print result
echo "<center><h1 style='color: aqua'>Post Added</h1><br /><h1 style='color: red'><a href='index.php'>Go To Home</a></h1></center>.";
} else {
// errors found
// print as list
echo "<center><h1 style='font-size:100px;color: aqua; text-shadow: 4px 1px 15px red;'>Error in Form</h1></center>";
echo "<ul>";
for ($x=0; $x<sizeof($errorList); $x++) {
echo "<li>$errorList[$x]";
}
echo "</ul></font>";
}
}
?>
Index.php
<html>
<head>
<meta charset="UTF-8">
<title>Exploit | Database</title>
<meta name='keywords' content='exploit,local,remote,arab,lfi,sql injection,buffer overflow,dos,ddos, priv8 exploit, 0day exploit, 2.6.18 kernel exploit 0day, localroot, priv8 exploit, how to deface, hack, how to hack, exploits, 0day exploits , x00x_team , '>
<meta name='description' content='Exploit Database Vulnerability reports, 0days, remote exploits, local exploits, security articles, tutorials and more.'>
<link rel="stylesheet" type="text/css" href="themes/default/style/style9.css" media="all">
<link rel='stylesheet' href='themes/system.css'>
<script src="jquery.min.js"> </script>
<style type="text/css">
body{ background:url(img/bg.png) !important; }
#code {
padding:5px;
border:1px dashed;
background-color:#353535;
direction: ltr;
text-align: left;
height:250px;
overflow-y:scroll;
}
textarea{
background-color:#353535;
color: red;
border-shadow: 4px 1px 18px white;
height:100%;
width:100%;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="typed.js" type="text/javascript"></script>
<script>
$(function(){
$("#typed").typed({
strings: ["welcome in <strong>Database</strong> Exploit.", "we <em>have</em> Big Database Exploit.", "And How Close It", "Enjoy in Site!"],
typeSpeed: 30,
backDelay: 500,
loop: false,
contentType: 'html', // or text
// defaults to false for infinite loop
loopCount: false,
callback: function(){ foo(); },
resetCallback: function() { newTyped(); }
});
$(".reset").click(function(){
$("#typed").typed('reset');
});
});
function newTyped(){ /* A new typed object */ }
function foo(){ console.log("Callback"); }
</script>
<link href="main.css" rel="stylesheet"/>
<style>
/* code for animated blinking cursor */
.typed-cursor{
opacity: 1;
font-weight: 100;
-webkit-animation: blink 0.7s infinite;
-moz-animation: blink 0.7s infinite;
-ms-animation: blink 0.7s infinite;
-o-animation: blink 0.7s infinite;
animation: blink 0.7s infinite;
}
#-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
#-webkit-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
#-moz-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
#-ms-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
#-o-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
</style>
<link rel="icon" href="Radiation.ico" type="image/ico" sizes="16x16">
</head>
<body><style>
#wg-rosebar {
width:100%;
position:fixed;
top:0;
left:0;
}
#wg-rosebarbtm {
border-bottom:3px solid #000;
background-color:#7f103c;
overflow:none;
width:100%;
height:40px;
position:fixed;
top:0;
left:0;
}
#wg-rosebarbtmdata {
color:#fff;
padding:5px;
}
#wg-rosebarbtmhide {
position:absolute;
top:4px;
right:12px;
width:20px;
height:20px;
cursor:pointer;
}
#wg-rosebarbtmshow {
position:absolute;
top:0;
right:5px;
width:30px;
height:25px;
cursor:pointer;
background-color:#F60;
padding-top:5px;
border-bottom:3px solid #000;
border-left:3px solid #000;
border-right:3px solid #000;
border-bottom-right-radius:5px;
border-bottom-left-radius:5px;
}
.wg-rosebarbtmdownarrow {
width:0;
height:0;
border-left:10px solid transparent;
border-right:10px solid transparent;
border-top:10px solid #CC5200;
}
.wg-rosebarbtmblock {
width:8px;
height:10px;
background-color:#CC5200;
}
.wg-rosebarbtmuparrow {
width:0;
height:0;
border-left:10px solid transparent;
border-right:10px solid transparent;
border-bottom:10px solid #CC5200;
}
</style>
<div id="wg-rosebar" >
<div id="wg-rosebarbtm" >
<style>
.wg-ribmenu span {
background:#7f103c;
display:inline-block;
color:#FFFFFF;
line-height:40px;
padding:0 1em;
margin-top:0.0em;
position:relative;
-webkit-transition: background-color 0.2s, margin-top 0.2s;
-moz-transition: background-color 0.2s, margin-top 0.2s;
-ms-transition: background-color 0.2s, margin-top 0.2s;
-o-transition: background-color 0.2s, margin-top 0.2s;
transition: background-color 0.2s, margin-top 0.2s;
}
.wg-ribmenu a:hover span {
background:#FFD204;
margin-top:0;
}
.wg-ribmenu span:before {
content: "";
position:absolute;
top:40px;
right:0;
border-left:0.5em solid #9B8651;
border-bottom:0.5em solid #7f103c;
}
.wg-ribmenu span:after {
content: "";
position:absolute;
top:40px;
left:0;
border-right:0.5em solid #9B8651;
border-bottom:0.5em solid #7f103c;
}
.wg-ribmenu a:link, .wg-ribmenu a:visited {
color:#000;
text-decoration:none;
float:right;
height:40px;
overflow:hidden;
}
</style>
<div class='wg-ribmenu'>
<a href='/index.html'><span><img class="fa-fa-home"/></span></a>
<a href='admin/index.php'><span>Add Post</span></a>
</div>
</div></div>
<div class="wrap">
<h1 class="h1" style="color: #ff0000">Welcome in Database</h1>
<div class="type-wrap">
<span id="typed" style="white-space:pre;"></span>
</div>
<div class='body'><h1 class='title'><a class='teko' href='index.php' title='Exploit Big Database'>Posts</a></h1><table border='1' align='center' width='98%'>
<tr class='trhead'>
<td width='10%'>Date</td>
<td class='left'>Title</td>
<td width='12%'>Author</td>
</tr>
<?php
include_once 'clude/conn.php';
$sql = "SELECT * FROM exploit";
$q = mysql_query($sql);
$num_row = mysql_num_rows($q);
while($articles = mysql_fetch_array($q)) {
?>
<tr class="exploit">
<td><?php echo $articles['date'];?></td>
<td><?php echo $articles['title']; ?></td>
<td><?php echo $articles['author'];?></td>
</tr>
<?php
}
mysql_close();
?>
</table> </div> </div>
</body>
</html>

I believe what you're looking for is Mod Rewrite, which involves editing the .htaccess file.
See https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
Also http://www.workingwith.me.uk/articles/scripting/mod_rewrite

solve is :
<?php
include_once 'clude/conn.php';
$sql = "SELECT * FROM posts";
$q = mysql_query($sql);
$num_row = mysql_num_rows($q);
while($articles = mysql_fetch_array($q)) {
?>
<div class="row"><div class="col-md-12"><div class="boxed">
<h1><?php echo $articles['title']; ?></h1>
<p><?php echo $articles['description']; ?></p>
<hr>
<?php
include_once 'clude/conn.php';
$sql = "SELECT * FROM store";
$w = mysql_query($sql);
$num_row = mysql_num_rows($w);
while($imagee = mysql_fetch_array($w)) {
?>
<img src="<?php echo $imagee['image']; ?>">
<?php
}
?>
<hr>
</div></div></div>
<?php
}
mysql_close();
?>
show_cat.php / example
<tr class="exploit">
<td><?php echo $ar['date']; ?></td>
<td><?php echo $ar['title']; ?></td>
<td><?php echo $ar['author']; ?></td>
</tr>
<?php
}
mysql_close();
?>

Related

PHP Customizing div to place next to each other

I have a problem. I created this code that shows products from my database like products:
<?php
include("connect.php");
session_start();
$status="";
if (isset($_POST['id']) && $_POST['id']!="")
{
$Id = $_POST['id'];
$result = mysqli_query($conn,"SELECT * FROM Producten WHERE `Id`='$Id'");
$row = mysqli_fetch_assoc($result);
$naam = $row['Naam'];
$id = $row['Id'];
$prijs = $row['Prijs'];
$foto = $row['Foto'];
$winkelwagen_array = array(
$id=>array(
'id'=>$id,
'naam'=>$naam,
'prijs'=>$prijs,
'hoeveelheid'=>1,
'foto'=>$foto)
);
if(empty($_SESSION["winkelwagen"]))
{
$_SESSION["winkelwagen"] = $winkelwagen_array;
$status = "<div class='box'>Product toegevoegd aan winkelwagen!</div>";
}
else
{
$_SESSION["winkelwagen"] = array_merge($_SESSION["winkelwagen"],$winkelwagen_array);
$status = "<div class='box'>Product toegevoegd aan winkelwagen!</div>";
}
}
?>
<html>
<head>
<link rel='stylesheet' href='css/style.css' type='text/css' media='all' />
</head>
<body>
<div style="width:700px; margin:50 auto;">
<?php
if(!empty($_SESSION["winkelwagen"]))
{
$winkelwagen_hoeveelheid = count(array_keys($_SESSION["winkelwagen"]));
?>
<div class="winkelwagen_div">
<img src="media/winkelwagen_logo.png" /> Winkelwagen<span><?php echo $winkelwagen_hoeveelheid; ?></span>
</div>
<?php
}
$result = mysqli_query($conn,"SELECT * FROM Producten");
while($row = mysqli_fetch_assoc($result))
{
echo "<div class='product_vak'>
<form method='post' actie=''>
<input type='hidden' name='id' value=".$row['Id']." />
<div class='foto'><img src='".$row['Foto']."' /></div>
<div class='naam'>".$row['Naam']."</div>
<div class='prijs'>€".$row['Prijs']."</div>
<button type='submit' class='koop'>Koop nu</button>
</form>
</div>";
}
mysqli_close($conn);
?>
<div style="clear:both;"></div>
<div class="melding_box" style="margin:10px 0px;">
<?php echo $status; ?>
</div>
</div>
</body>
</html>
with this css:
.product_vak {
float:left;
padding: 10px;
text-align: center;
}
.product_vak:hover {
box-shadow: 0 0 0 2px #e5e5e5;
cursor:pointer;
}
.product_vak .naam {
font-weight:bold;
}
.product_vak .koop {
text-transform: uppercase;
background: #F68B1E;
border: 1px solid #F68B1E;
cursor: pointer;
color: #fff;
padding: 8px 40px;
margin-top: 10px;
}
.product_vak .koop:hover {
background: #f17e0a;
border-color: #f17e0a;
}
.melding_box .box{
margin: 10px 0px;
border: 1px solid #2b772e;
text-align: center;
font-weight: bold;
color: #2b772e;
}
.table td {
border-bottom: #F0F0F0 1px solid;
padding: 10px;
}
.winkelwagen_div {
float:right;
font-weight:bold;
position:relative;
}
.winkelwagen_div a {
color:#000;
}
.winkelwagen_div span {
font-size: 12px;
line-height: 14px;
background: #F68B1E;
padding: 2px;
border: 2px solid #fff;
border-radius: 50%;
position: absolute;
top: -1px;
left: 13px;
color: #fff;
width: 14px;
height: 13px;
text-align: center;
}
.winkelwagen .verwijderen {
background: none;
border: none;
color: #0067ab;
cursor: pointer;
padding: 0px;
}
.winkelwagen .verwijderen:hover {
text-decoration:underline;
}
But when I load the page I see 2 products above each other in a very very large size. Now how can I get them to load next to each other and in a smaller size, because now they are filling the whole screen per product!
I already tried giving product_vak a width, but the image doesn't size with that!
How can I fix this?
try like this
.product_vak {
float:left;
padding: 10px;
text-align: center;
width:40%;

jQuery overlaps my other elements in page

I used the following code for showing suggestions wile typing. It's working well, but my other elements overlap the my search suggestion. How can I resolve this?
Code in <head>:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js">
</script>
<script>
function suggest(inputString){
if(inputString.length == 0) {
$('#suggestions').fadeOut();
} else {
$('#country').addClass('load');
$.post("search.php", {queryString: ""+inputString+""}, function(data){
if(data.length >0) {
$('#suggestions').fadeIn();
$('#suggestionsList').html(data);
$('#country').removeClass('load');
}
});
}
}
function fill(thisValue) {
$('#country').val(thisValue);
setTimeout("$('#suggestions').fadeOut();", 600);
}
</script>
search.php:
<?php
include('inc/config.php');
include('inc/func.php');
$queryString=$_POST['queryString'];
if(isset($_POST['queryString'])) {
if(strlen($queryString) >0) {
$query = mysql_query("SELECT person_id,name,type,photo FROM person WHERE name LIKE '$queryString%' or person_id like '$queryString%' LIMIT 5");
if($query) {
echo '<ul>';
while ($result = mysql_fetch_array($query)) {
?>
<li>
<a href="view">
<table>
<tr>
<td>
<img src="<?php if($result['photo']=="0"){ echo "data/img/default.png";}else{ echo $result['photo'];}?>" width="60px" height="60px">
</td>
<td width="20px">
</td>
<td valign="top">
<h2><?php echo $result['name'];?></h2>
<h4><?php if($result['type']=='1'){echo "Staff";}elseif($result['type']=='2'){echo "Parent";}else{echo "Student";}?></h4>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td valign="top">
<h4>
<?php
if($result['type']=='3')
{
echo "Roll No: ".get_data('student','rollno',$result['person_id']);
}
?>
</h4>
<h4>
<?php
if($result['type']=='3')
{
$section_id=get_data('student','section_id',$result['person_id']);
$section_name=get_data('section','name',$section_id);
$class_id=get_data('section','class_id',$section_id);
$class_name=get_data('class','name',$class_id);
echo "Class: ".ucfirst($class_name)."(".$section_name.")";
}
?>
</h4>
</td>
</tr>
</table>
</a>
</li>
<?php
}
echo '</ul>';
} else {
echo 'sorry';
}
} else {
echo 'sorry';
}
} else {
echo 'There should be no direct access to this script!';
}
?>
CSS code:
#result {
height:20px;
font-size:16px;
font-family:Arial, Helvetica, sans-serif;
color:#333;
padding:5px;
margin-bottom:10px;
background-color:#FFFF99;
}
#country{
padding:3px;
border:1px #CCC solid;
font-size:17px;
}
.suggestionsBox {
position: absolute;
left: 440px;
top:35px;
margin: 0px 0px 0px 0px;
width: 570px;
padding:0px;
background-color: #71a4e3;
border-top: 0px solid #000;
color: #ffffff;
}
.suggestionList {
margin: 0px;
padding: 0px;
}
.suggestionList ul li {
list-style:none;
margin: 0px;
padding: 6px;
border-bottom:3px solid #000;
cursor: pointer;
min-height:50px;
}
.suggestionList ul li:hover {
background-color: #ffffff;
color:#000;
}
.suggestionList a
{
background-color: #ffffff;
color:#000;
}
ul {
font-family:Arial, Helvetica, sans-serif;
font-size:13px;
color:#fffff;
padding:0;
margin:0;
}
.load{
background-image:url(../img/ajaxLoader/loader01.gif);
background-position:right;
background-repeat:no-repeat;
}
#suggest {
position:relative;
}
Give your main content container a position:relative and a z-index:1...then, give your suggestion box a z-index:100 or higher. That should put your suggestions above other content on the page...if I'm understanding your need correctly.

Proplem in div right align?

i have php program that contain div main_wrapper that div have two sub div resultwrapper and adv_right. I want adv_right div exactly right side of the resultwrapper div.When i'm use float mean that div present outside of the main_wrapper div.
<style>
.resultwrapper{width:990px; margin: 10px auto 10px auto; clear:both; }
.resultitem{ float: left;
height: 170px;
margin-bottom: 0px;
margin-left: 10px;
min-height: 130px;
width:218px;}
.resultleftitem{padding-left:0;margin-left:0px;}
.resultitem img{border:dotted 1px #666; padding:6px;}
.resultitem img:hover{border:solid 1px #F60;}
.resultitem h4{font-size:12px; font-weight:bold; color:#249ce9; margin-top:5px; }
.resultitem a{color:#249ce9;}
.resultitem .caption{color:#9c9c9c; font-size:12px; display:block; margin-top:6px; text-align:justify;}
</style>
<div class="main_warpper">
<div class="resultwrapper">
<?php
while($row = mysql_fetch_array($rs)) {
$id=$row['id'];
$type=$row['type'];
$location=$row['location'];
if(file_exists("properties//". $imageloc ."//thumb.jpg") )
{
$thumb_img="properties/". $imageloc ."/thumb.jpg";
} else {
$thumb_img="images/default.jpg";
}
if($cnt==0 || $cnt ==4 ) $newResult=true; else $newResult=false;
?>
<div id="parent" >
<div class="resultitem <?php if($newResult) echo ' resultleftitem'; ?>" id="resultitem"> <a href="viewpropdetails.php?id=<?php echo $id;?>" target="_blank">
<img id="parent" src="<?php echo $thumb_img; ?>" alt="<?php $new=strtolower($heading); echo ucwords($new); ?>" title="<?php $new=strtolower($heading); echo ucwords($new); ?>" width="100" height="100" /></a>
<div class="itemdetails">
<h4 id="linkheading"><?php echo $type ." # ".$location; ?></h4>
<span class="box"><?php echo cropStr($desc,$MAX_DESC); ?></span>
</div>
</div>
</div>
<?php
$cnt++; } ?>
</div>
<div class="adv_right" style=" clear:both; width:15%; float:right;height:300px; background-color:#999999;">
</div>
</div>
Please try it,
Remove clear:both; from both div and set width what u want ,,
Please try this code you want like this ??
<style>
.resultwrapper {
margin: 10px auto 10px auto;
}
.resultitem {
float: left;
height: 170px;
margin-bottom: 0px;
margin-left: 10px;
min-height: 130px;
width:218px;
}
.resultleftitem {
padding-left:0;
margin-left:0px;
}
.resultitem img {
border:dotted 1px #666;
padding:6px;
}
.resultitem img:hover {
border:solid 1px #F60;
}
.resultitem h4 {
font-size:12px;
font-weight:bold;
color:#249ce9;
margin-top:5px;
}
.resultitem a {
color:#249ce9;
}
.resultitem .caption {
color:#9c9c9c;
font-size:12px;
display:block;
margin-top:6px;
text-align:justify;
}
</style>
<div class="main_warpper">
<div class="resultwrapper">
<?php
while($row = mysql_fetch_array($rs)) {
$id=$row['id'];
$type=$row['type'];
$location=$row['location'];
if(file_exists("properties//". $imageloc ."//thumb.jpg") )
{
$thumb_img="properties/". $imageloc ."/thumb.jpg";
} else {
$thumb_img="images/default.jpg";
}
if($cnt==0 || $cnt ==4 ) $newResult=true; else $newResult=false;
?>
<div id="parent" >
<div class="resultitem <?php if($newResult) echo ' resultleftitem'; ?>" id="resultitem"> <img id="parent" src="<?php echo $thumb_img; ?>" alt="<?php $new=strtolower($heading); echo ucwords($new); ?>" title="<?php $new=strtolower($heading); echo ucwords($new); ?>" width="100" height="100" />
<div class="itemdetails">
<h4 id="linkheading"><?php echo $type ." # ".$location; ?></h4>
<span class="box"><?php echo cropStr($desc,$MAX_DESC); ?></span> </div>
</div>
</div>
<?php
$cnt++; } ?>
</div>
<div class="adv_right" style="width:15%; float:right;height:300px; background-color:#999999;">23123 </div>
</div>
add float:left here
<div class="resultwrapper" style="float:left;">
and rempove clear:both and add float:left
<div class="adv_right" style=" clear:both; width:15%; float:left;height:300px;
background-color:#999999;">
see demo here ....http://jsfiddle.net/6e4xN/1/
when you going to use this code it will not work with more than 7-8 elements, to work when you have more elements then use below stylesheet.
<style>
.resultwrapper {
margin: 10px auto 10px auto;
width:80%;
float:left;
}
.resultitem {
float: left;
height: 170px;
margin-bottom: 0px;
margin-left: 10px;
min-height: 130px;
width:150px;
}
.resultleftitem {
padding-left:0;
margin-left:0px;
}
.resultitem img {
border:dotted 1px #666;
padding:6px;
}
.resultitem img:hover {
border:solid 1px #F60;
}
.resultitem h4 {
font-size:12px;
font-weight:bold;
color:#249ce9;
margin-top:5px;
}
.resultitem a {
color:#249ce9;
}
.resultitem .caption {
color:#9c9c9c;
font-size:12px;
display:block;
margin-top:6px;
text-align:justify;
}
</style>
Let me know if it works for you or not.
I guess there is some problem in the code. You CANNOT use the same ID for multiple elements in a page. Secondly when you are using percent width for the adv_right div, why don't you use the same for resultwrapper div with both the resultwrapper & adv_right divs floated left and no clear:both in the css. I feel this should solve your problem.

PHP Echo Returns Blank Page

I have "checks" in here and if something happens, it will echo a phrase like The username you supplied is already in use or whatever. When it DOES display it though, it'll only display it on a blank page with that text. What is wrong here?
PHP
<?php
include('./dbconnect/global.php');
if ($_POST['register']) {
$username = mysql_real_escape_string(strip_tags($_POST['username']));
$password = mysql_real_escape_string(strip_tags($_POST['password']));
$email = mysql_real_escape_string(strip_tags($_POST['email']));
if (!$username||!$password||!$email)
echo "PLease Fill in The Required Fields";
else {
//check if username is taken
$check = mysql_query("SELECT * FROM users WHERE username='$username'");
if (mysql_num_rows($check) >= 1)
echo "The Username you Supplied Is Already in Use! <a href='./register'>Back</a>";
$check2 = mysql_query("SELECT * FROM users WHERE email='$email'");
if (mysql_num_rows($check) >= 1)
echo "The Email you Supplied Is Already in Use! <a href='./register'>Back</a>";
else {
$password2 = md5($password);
$register = mysql_query("value and stuff)") or die(mysql_error());
echo "Thanks for registering, $username! <a href='./index'>Home</a>";
}
}
}
else {
?>
HTML
<html>
<head>
<title>CoreCrafters</title>
<link rel="stylesheet" type="text/css" href="./css/main.css">
</head>
<body>
<?php include('./include/nbar.php') ?>
<div id="main">
<div id="register">
<div id="wrapper">
<form action="register" method="POST">
Username
<br />
<input type="username" name="username">
<br />
Password
<br />
<input type="password" name="password">
<br />
Email
<br />
<input type="email" name="email">
<br /><br />
<input type="submit" name="register" value="Register">
</form>
</div>
</div>
</div>
<?php include('./include/footer.php') ?>
</body>
</html>
Ending PHP (From ELSE at end)
<?php
}
?>
CSS
body {
margin: 0;
padding: 0;
background-color: #EEE;
}
#headerbar {
width: 100%;
background-color: #000;
}
a {
color: #069;
font-weight: bold;
text-decoration: none;
transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-webkit-transition: all 0.2s linear;
}
a:hover {
color: #c00;
}
#nav {
padding: 0;
width: 100%;
float: left;
list-style: none;
margin: 0 0 3em 0;
background-color: #f2f2f2;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
#nav li {
float: left;
}
#nav li a {
color: #069;
display: block;
font-weight: bold;
padding: 8px 15px;
text-decoration: none;
transition: all 0.2s linear;
border-right: 1px solid #ccc;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-webkit-transition: all 0.2s linear;
}
#nav li a:hover {
color: #c00;
background-color: #fff;
}
#footer {
width: 94%;
padding: 10px;
margin-top: 10px;
margin-left: auto;
padding-left: 0px;
text-align: center;
margin-right: auto;
padding-right: 0px;
border: 1px solid #DDD;
background-color: #FFF;
}
#main {
width: 94%;
margin-top: 50px;
min-height: 500px;
margin-left: auto;
margin-right: auto;
border: 1px solid #DDD;
background-color: #FFF;
}
#register {
width: 15%;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
text-align: center;
background-color: #CCC;
border: 1px solid #AAA;
}
#logbar {
width: 150px;
float: right;
min-height: 36px;
padding-left: 5px;
padding-right: 50px;
background-color: #DDD;
}
As requested, I posted most of the page onto here.
Your webpage has no content except that echo, so it is echo-ing it on a blank page because you told it to.
Update: Code
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8"> <!-- UXSS UTF-7 (IE6) prevention -->
<title>CoreCrafters</title>
<link rel="stylesheet" type="text/css" href="./css/main.css">
</head>
<body>
<?php #include('./include/nbar.php'); ?>
<div id="main">
<div id="register">
<div id="wrapper">
<form method="POST">
Username<br /><input type="username" name="username"><br />
Password<br /><input type="password" name="password"><br />
Email<br /><input type="email" name="email"><br /><br />
<input type="submit" name="register" value="Register">
</form>
</div>
<?php
#include('./dbconnect/global.php');
if (isset($_POST['register'])) {
if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) {
die('Please fill out the required fields.');
} else {
$query = mysql_query("SELECT * FROM users WHERE username = '" . mysql_real_escape_string($_POST['username']) . "'");
if (mysql_num_rows($query)) { die('The username you provided is already in use!'); }
$query = mysql_query("SELECT * FROM users WHERE email = '" . mysql_real_escape_string($_POST['email']) . "'");
if (mysql_num_rows($query)) { die('The email you provided is already in use!'); }
/** Insert values **/
echo 'Thanks for registering, ' . htmlentities($_POST['username'], ENT_QUOTES) . '!'; /** Normal XSS prevention **/
}
}
?>
</div>
</div>
<?php #include('./include/footer.php'); ?>
</body>
</html>
I believe you are missing semicolons for your include statements (inside the HTML block). Such as:
<?php include('./include/footer.php'); ?>
If that doesn't solve it, you should check your error log. A completely blank page is often what you get when the PHP parser was unable to parse your code.

Passed session variable displaying wrong info inside a lightbox

I am creating an application in which a folder gets created by the username, and inside that folder, another folder gets created dynamically called Profile_Pics.
I have used Ajax Script also.
Its just a bit of Facebook album type application. Now the problem is that, for this thing I am using session, and user can created other folders also say like "My_Pics" inside his folder. The folder is for storing photos.
The path of the created album inside username folder is like this
Candidate_Pics/sex/Username/album_name
Example:
If a male of username saz26 registers first, then the folder Profile_pics will be created by default.
Candidate_Pics/Male/saz26/Profile_pics
If he creates another album say My_Pics then:
Candidate_Pics/Male/saz26/My_pics
Where under My_Pics he can store other pics.
Now I have created this page, and I need to work with session. And also I use session variable.
Here's my photos.php file:
<?php
session_start();
ob_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" media="screen" href="CSS/main.css" />
<link rel="stylesheet" type="text/css" media="screen" href="CSS/style.css" />
<script type="text/javascript" src="AJAX/AjaxCreateAlbum.js"></script>
<script>
function showalbum()
{
document.getElementById('AlbumDiv').style.display = "block";
document.getElementById('fade').style.display = "block"
return false;
}
</script>
</head>
<body>
<div id="pictures">
<h2>Photos</h2>
<form id="picture_form" name="picture_form" method="post" action="javascript:getfolder(document.getElementById('picture_form'));">
<table align="center" width="650" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="50px" align="center"/>
<td width="100px" align="center">
<label for="album_name">Create Album::</label>
</td>
<td width="50px" align="center"/>
<td width="100px" align="center">
<input type="text" name="album_name" id="album_name" class="textfield" style="width: 100px;"/>
</td>
<td width="50px" align="center"/>
<td width="100px" align="center">
<input type="submit" name="submit" id="submit" class="button" value="Create Album" />
</td>
<td width="50px" align="center"/>
<td width="100px" align="center">
<div id="album_report"></div>
</td>
<td width="50px" align="center"/>
</tr>
<tr>
<td colspan="9" height="20px"/>
</tr>
</table>
<?php
$folder=array();
if(is_dir("Candidate_Pics/". "$_SESSION[sex]". "/" . "$_SESSION[logged_user]"))
{
$dir=opendir("Candidate_Pics/". "$_SESSION[sex]". "/" . "$_SESSION[logged_user]");
$nofiles=0;
while ($file = readdir($dir))
{
if ($file != '.' && $file != '..')
{
$nofiles++;
$files[$nofiles]=$file;
}
}
closedir($dir);
}
/* populate sample data */?>
<?php
/* how many columns */
$column_number='3';
/* html table start */
?><table border="1" cellspacing="5" cellpadding="5" width="650px" align="center"
><?php
$recordcounter=1; /* counts the records while they are in loop */
foreach($files as $record) {
/* decide if there will be new Table row (<TR>) or not ... left of division by column number is the key */
if($recordcounter%$column_number==1){ echo "<tr>"; }
?>
<td width="200px" align="center">
<?php echo $record;?><br/>
<?php
$_SESSION['album_name']="Candidate_Pics/$_SESSION[sex]/$_SESSION[logged_user]/$record";
echo "$_SESSION[album_name]"; ?>
<a href="javascript:void(0)" onClick="showalbum();" ><img src="Images/folder.png" width="200px"/></a><br/>
<input type="button" name="delete" id="delete" value="delete" class="button"/>
</td>
<?php
/* decide if there will be end of table row */
if($recordcounter%$column_number==0){ echo "</tr>"; }
$recordcounter++; /* increment the counter */
}
if(($recordcounter%$column_number)!=1){ echo "</tr>"; }
?></table>
</form>
</div>
<div id="AlbumDiv" class="white_content">
<table align="center" cellpadding="0" cellspacing="0" border="0" width="382px">
<tr>
<td height="16px">
<a href="javascript:void(0)"
onclick="document.getElementById('AlbumDiv').style.display =
'none';document.getElementById('fade').style.display='none'">
<img src="images/close-icon.png" style="border-style: none; border-color: inherit;
border-width: 0px; height: 17px; width: 16px;" align="right" /></a>
</td>
</tr>
<tr>
<td>
<?php echo "$_SESSION[album_name]";?>
</td>
</tr>
<tr>
<td height="16px"/>
</tr>
</table>
</div>
<div id="fade" class="black_overlay">
</div>
</body>
</html>
the problem is that the line
echo "$_SESSION[album_name]";
inside the foreach loop is giving rite result for each record(rather say folder),
but the line
echo "$_SESSION[album_name]";
inside the AlbumDiv(used for the lightbox),
is only giving the result with Profile_pics, i.e. "Candidate_Pics/Male/saz26/Profile_pics"
no matter which ever folder image i click...
following is the AjaxCreateAlbum.js script
var http_request = false;
function makePOSTalbum(url, parameters)
{
http_request = false;
if (window.XMLHttpRequest)
{
// Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
}
else if (window.ActiveXObject)
{ // IE
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!http_request)
{
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertAlbumCreated;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}
function alertAlbumCreated()
{
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
//alert(http_request.responseText);
result = http_request.responseText;
document.getElementById('album_report').innerHTML = result;
}
else
{
alert(http_request.status);
}
}
}
function getfolder(obj)
{
alert("huhu");
var poststring = "album_name=" + encodeURI( document.getElementById("album_name").value );
alert(poststring);
makePOSTalbum('createalbum.php', poststring);
}
And following is the createalbum.php script:
<?php
session_start();
if(mkdir("Candidate_Pics/$_SESSION[sex]/$_SESSION[logged_user]/".$_POST['album_name']))
echo "done";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
And following is the stylesheet file:
.black_overlay
{
display: none;
position: fixed;
top: 0%;
left: 0%;
width: 100.7%;
height: 100%;
background-color: black;
z-index: 1001;
-moz-opacity: 0.8;
opacity: .80;
filter: alpha(opacity=80);
}
.white_content
{
display: none;
position: fixed;
top: 37%;
left: 32%;
width: 382px;
padding: 0px;
border: 0px solid #a6c25c;
background: url(loginpanel.png);
z-index: 1002;
overflow: auto;
}
.headertext
{
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #f19a19;
font-weight: bold;
}
.textfield
{
border: 1px solid #a6c25c;
width: 100px;
border : 1px solid #999;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
_border-radius: 5px;
}
.dropdown
{
border: 1px solid #a6c25c;
border : 1px solid #999;
border-radius: 5px;
}
.button2
{
background-color: #a6c25c;
color: White;
font-size: 11px;
font-weight: bold;
border: 1px solid #7f9db9;
width: 100px;
}
.button
{
zoom: 1;
background: url(button.png);
color: White;
font-size: 11px;
font-weight: bold;
border: 1px solid #7f9db9;
-khtml-border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
#border-radius: 5px;
_border-radius: 5px;
border-radius: 5px;
}
#loading{
text-align: center;
visibility: hidden;
}
#content{
color: #000000;
margin: 0 0 20px 0;
line-height: 1.3em;
font-size: 14px;
}
.text
{
border: 1px solid #a6c25c;
border : 1px solid #999;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-khtml-border-radius: 5px;
_border-radius: 5px;
}
/******* TOP *******/
#topmenu{
margin: 0 0;
padding: 0 0 0 0;
background: url(button.png);
}
/******* /TOP *******/
/******* MENU *******/
#topmenu #menu_main{
float: left;
list-style-type: none;
margin: 0px 0 0px 0px;
}
#topmenu #menu_main li{
float: left;
text-transform: uppercase;
color: #000099;
margin-left: 50px;
margin-right: 50px;
}
#topmenu #menu_main li:hover{
color: #6fa5fd;
cursor: pointer;
}
/******* /MENU *******/
/******* FOOTER *******/
#footer{
background: #efefef;
border: 1px solid #d0ccc9;
padding: 5px;
color: #7e7e7e;
font-size: 11px;
text-align: right;
}
/******* /FOOTER *******/
If I'm reading this correctly, your session variable is being set multiple times within a foreach loop, and then later called. Every time you write to that session variable within a loop, it overwrites the previous value, so once that loop is done, the only value the session variable will hold is the very last one from the loop.
Luckily you can remedy that pretty easily, since you're writing a javascript function call in an <a> tag in the next line. You can change that to echo the album name (while you're still in the loop) as what will on the client side be a Javascript argument.
<a href="javascript:void(0)" onClick="showalbum();" ><img src="Images/folder.png" width="200px"/></a><br/>
Becomes:
<a href="javascript:void(0)" onClick="showalbum('<?php echo $_SESSION['album_name']; ?>');" ><img src="Images/folder.png" width="200px"/></a><br/>
Then all you have to do is change your showalbum function to accept an argument, and use it to set the content of the intended <td> element. For example:
function showalbum(album_name)
{
document.getElementById('AlbumDiv').style.display = "block";
document.getElementById('fade').style.display = "block"
document.getElementById('albumName').innerHTML = album_name; // this line added
return false;
}
And in the PHP,
<td>
<?php echo "$_SESSION[album_name]";?>
</td>
Becomes:
<td id="albumName"></td>

Categories