Counter is not working properly - php

I am basically creating a calendar where I want to show the attendances of students. If the student is present or absent then the counter should increase to +1 respectively. But the problem is that if in somewhere the attendance in calendar date is not recorded then the counter fails to increase the value of present or absent.
This is the code:
$present_sids = explode(",",$a['present_sids']);
$absent_sids = explode(",",$a['absent_sids']);
$leave_sids = explode(",",$a['leave_sids']);
if ($a['att_date'] == "1")
{
if (in_array($sid,$present_sids))
{
$red_green_1 = '70ff7d';
$present_counter = '1';
}
elseif (in_array($sid,$absent_sids))
{
$red_green_1 = 'ff8b70';
$absent_counter = '1';
if (in_array($sid,$leave_sids))
{
$l_1 = ' (L)';
}
else
{
$l_1 = '';
}
}
}
if ($a['att_date'] == "2")
{
if (in_array($sid,$present_sids))
{
$red_green_2 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_2 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_2 = ' (L)';
}
else
{
$l_2 = '';
}
}
}
if ($a['att_date'] == "3")
{
if (in_array($sid,$present_sids))
{
$red_green_3 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_3 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_3 = ' (L)';
}
else
{
$l_3 = '';
}
}
}
if ($a['att_date'] == "4")
{
if (in_array($sid,$present_sids))
{
$red_green_4 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_4 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_4 = ' (L)';
}
else
{
$l_4 = '';
}
}
}
if ($a['att_date'] == "5")
{
if (in_array($sid,$present_sids))
{
$red_green_5 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_5 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_5 = ' (L)';
}
else
{
$l_5 = '';
}
}
}
if ($a['att_date'] == "6")
{
if (in_array($sid,$present_sids))
{
$red_green_6 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_6 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_6 = ' (L)';
}
else
{
$l_6 = '';
}
}
}
if ($a['att_date'] == "7")
{
if (in_array($sid,$present_sids))
{
$red_green_7 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_7 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_7 = ' (L)';
}
else
{
$l_7 = '';
}
}
}
if ($a['att_date'] == "8")
{
if (in_array($sid,$present_sids))
{
$red_green_8 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_8 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_8 = ' (L)';
}
else
{
$l_8 = '';
}
}
}
if ($a['att_date'] == "9")
{
if (in_array($sid,$present_sids))
{
$red_green_9 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_9 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_9 = ' (L)';
}
else
{
$l_9 = '';
}
}
}
if ($a['att_date'] == "10")
{
if (in_array($sid,$present_sids))
{
$red_green_10 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_10 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_10 = ' (L)';
}
else
{
$l_10 = '';
}
}
}
if ($a['att_date'] == "11")
{
if (in_array($sid,$present_sids))
{
$red_green_11 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_11 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_11 = ' (L)';
}
else
{
$l_11 = '';
}
}
}
if ($a['att_date'] == "12")
{
if (in_array($sid,$present_sids))
{
$red_green_12 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_12 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_12 = ' (L)';
}
else
{
$l_12 = '';
}
}
}
if ($a['att_date'] == "13")
{
if (in_array($sid,$present_sids))
{
$red_green_13 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_13 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_13 = ' (L)';
}
else
{
$l_13 = '';
}
}
}
if ($a['att_date'] == "14")
{
if (in_array($sid,$present_sids))
{
$red_green_14 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_14 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_14 = ' (L)';
}
else
{
$l_14 = '';
}
}
}
if ($a['att_date'] == "15")
{
if (in_array($sid,$present_sids))
{
$red_green_15 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_15 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_15 = ' (L)';
}
else
{
$l_15 = '';
}
}
}
if ($a['att_date'] == "16")
{
if (in_array($sid,$present_sids))
{
$red_green_16 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_16 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_16 = ' (L)';
}
else
{
$l_16 = '';
}
}
}
if ($a['att_date'] == "17")
{
if (in_array($sid,$present_sids))
{
$red_green_17 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_17 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_17 = ' (L)';
}
else
{
$l_17 = '';
}
}
}
if ($a['att_date'] == "18")
{
if (in_array($sid,$present_sids))
{
$red_green_18 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_18 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_18 = ' (L)';
}
else
{
$l_18 = '';
}
}
}
if ($a['att_date'] == "19")
{
if (in_array($sid,$present_sids))
{
$red_green_19 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_19 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_19 = ' (L)';
}
else
{
$l_19 = '';
}
}
}
if ($a['att_date'] == "20")
{
if (in_array($sid,$present_sids))
{
$red_green_20 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_20 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_20 = ' (L)';
}
else
{
$l_20 = '';
}
}
}
if ($a['att_date'] == "21")
{
if (in_array($sid,$present_sids))
{
$red_green_21 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_21 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_21 = ' (L)';
}
else
{
$l_21 = '';
}
}
}
if ($a['att_date'] == "22")
{
if (in_array($sid,$present_sids))
{
$red_green_22 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_22 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_22 = ' (L)';
}
else
{
$l_22 = '';
}
}
}
if ($a['att_date'] == "23")
{
if (in_array($sid,$present_sids))
{
$red_green_23 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_23 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_23 = ' (L)';
}
else
{
$l_23 = '';
}
}
}
if ($a['att_date'] == "24")
{
if (in_array($sid,$present_sids))
{
$red_green_24 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_24 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_24 = ' (L)';
}
else
{
$l_24 = '';
}
}
}
if ($a['att_date'] == "25")
{
if (in_array($sid,$present_sids))
{
$red_green_25 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_25 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_25 = ' (L)';
}
else
{
$l_25 = '';
}
}
}
if ($a['att_date'] == "26")
{
if (in_array($sid,$present_sids))
{
$red_green_26 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_26 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_26 = ' (L)';
}
else
{
$l_26 = '';
}
}
}
if ($a['att_date'] == "27")
{
if (in_array($sid,$present_sids))
{
$red_green_27 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_27 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_27 = ' (L)';
}
else
{
$l_27 = '';
}
}
}
if ($a['att_date'] == "28")
{
if (in_array($sid,$present_sids))
{
$red_green_28 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_28 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_28 = ' (L)';
}
else
{
$l_28 = '';
}
}
}
if ($a['att_date'] == "29")
{
if (in_array($sid,$present_sids))
{
$red_green_29 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_29 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_29 = ' (L)';
}
else
{
$l_29 = '';
}
}
}
if ($a['att_date'] == "30")
{
if (in_array($sid,$present_sids))
{
$red_green_30 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_30 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_30 = ' (L)';
}
else
{
$l_30 = '';
}
}
}
if ($a['att_date'] == "31")
{
if (in_array($sid,$present_sids))
{
$red_green_31 = '70ff7d';
$present_counter = $present_counter+1;
}
elseif (in_array($sid,$absent_sids))
{
$red_green_31 = 'ff8b70';
$absent_counter = $absent_counter+1;
if (in_array($sid,$leave_sids))
{
$l_31 = ' (L)';
}
else
{
$l_31 = '';
}
}
}
This is the image of calendar:
As you can see that total presents are 6 but the total presents counter is showing only 4
Please help

I actually got it working. What I have done is to drop the table and re-install the table again. I don't know why and how but its now working.
Thanks for every one! :)

Related

I need to put resize image 150x130

I need help with image resize I don't know how to put in
<?php
if (isset($_POST['newcover'])) {
////GET image uploading settings
$select_upload_options = mysql_query("SELECT * FROM covers_submit_options");
$uop = mysql_fetch_assoc($select_upload_options);
$poster = $uop['cover_who_post'];
$approve = $uop['cover_approve'];
$server = $uop['cover_server'];
$default_user = $uop['cover_default_user'];
$cover_title = $_POST['title'];
$cover_desc = $_POST['desc'];
$cover_desc2 = $_POST['desc2'];
$cover_date = $_POST['date'];
$cover_tags = $_POST['tags'];
$cover_okvir = $_POST['okvir'];
$cover_velicina = $_POST['velicina'];
$cover_image2 = $_POST['image2'];
$cover_category = $_POST['huge'];
if ($poster != 'user' && $_SESSION['userid'] == '') {
$poster_user = $default_user;
} else {
$poster_user = $_SESSION['userid'];
}
if ($cover_title == '') {
$post_error = '<div class="alert alert-danger"><h3>Unesite Ime i Prezme</h3></div>';
} elseif ($cover_category == '') {
$post_error = '<div class="alert alert-danger"><h3>Izaberite Grad ii Općinu</h3></div>';
} elseif ($cover_date == '') {
$post_error = '<div class="alert alert-danger"><h3>Unesite Datum-Godište Npr. 1965-2016</h3></div>';
} elseif ($cover_okvir == '') {
$post_error = '<div class="alert alert-danger"><h3>Izaberite Izgled Osmrtnice</h3></div>';
} elseif ($poster_user == '') {
$poster_user = '1';
} elseif ($_FILES['photo']['size'] == '1') {
$post_error = '<div class="alert alert-danger"><h3>Please Select Image</h3></div>';
} else {
$post_error = '';
}
if ($post_error == '') {
if ($server == 'amazon') {
////////UPLOAD TO AMAZON/////////////////////
include('includes/amazonUpload.php');
////////UPLOAD TO AMAZON/////////////////////
} else {
////////////REGULAR UPLOADER TO SERVER/////////
list($file, $error) = upload('photo', 'images/covers/', 'jpg,jpeg,gif,png');
list($width, $height, $type, $attr) = ('images/covers/' . $file);
////////////Da bi upload slike mogao da radi uklonio sam dio koda orginal kod je ovaj dolje getimagesize prije zagrade images/covers /////////
if ($width < 0 || $height < 0) {
$post_error = "<div class='alert alert-danger'><h3>The Cover is Small<br>Please note that the Minimum allowed hight is 300px and Minimum Width is 800px </h3></div>";
unlink('images/covers/' . $file);
} else {
$image = 'images/covers/' . $file;
}
////////////REGULAR UPLOADER TO SERVER/////////
$error = $post_error;
}
////Store Into Database
if (!$error) {
$string = $slug;
if (strlen($string) != mb_strlen($string, 'utf-8')) {
$slug = date("M-D-His");
} else {
$slug = preg_replace("/[^a-zA-Z0-9_\-]/", '', $cover_title);
//$slug = preg_replace('/\s+/', '-', $cover_title);
$slug = strtolower($slug);
}
$is_slug_exists = mysql_query("SELECT * FROM covers_posts WHERE post_slug = '$slug' ");
$slug_exsits = mysql_num_rows($is_slug_exists);
if ($slug_exsits != '0') {
$slug = $slug . '-' . date('sy');
} else {
$slug = $slug;
}
$cover_datum = date("d-m-Y");
$insert = mysql_query("INSERT INTO covers_posts VALUES ('',
'$cover_title',
'$cover_desc',
'$cover_desc2',
'$cover_date',
'$cover_tags',
'$cover_okvir',
'$cover_velicina',
'$slug',
'$image',
'$cover_image2',
'$cover_category',
'1',
'$poster_user',
'$approve',
'0',
'0',
'0',
'$cover_datum'
) ");
order_badge($poster_user);
$post_error = '<div class="alert alert-success"><h3>Uspješno Ste Dodali Osmrtnicu , Prebacit će vas za 5 sekundi<br>
Ukolko ste zastali Kliknite Ovde
</h3></div>';
$redir = 'osmrtnica-' . $slug . '.html';
redirect($redir, '5');
} else {
$post_error = '<div class="alert alert-danger"><h3>' . $error . '</h3></div>';
}
} else {
$post_error = $post_error;
}
$smarty->assign('UploadResult', $post_error);
}
ok I know it is older script and I changed later in mysqli connection.
I read manual about upload and resize image now it is resize image but all image are black
elseif ($cover_okvir == '') {
$post_error = '<div class="alert alert-danger"><h3>Izaberite Izgled Osmrtnice</h3></div>';
}
elseif ($poster_user == '') {
$poster_user = '1';
}else{
////////////REGULAR UPLOADER TO SERVER/////////
list($file,$error) = upload('photo','images/covers/','jpg,jpeg,gif,png');
list($width, $height, $type, $attr) = getimagesize('images/covers/'.$file);
$width = 140;
$height = 150;
////////////REGULAR UPLOADER TO SERVER/////////
$src = imagecreatefromstring('images/covers/'.$file);
$dst = imagecreatetruecolor($width,$height);
imagecopyresampled($dst,$src,0,0,0,0,$width,$height);
imagedestroy($src);
imagepng($dst,'images/covers/'.$file); // adjust format as needed
imagedestroy($dst);
}
$image = 'images/covers/'.$file;
enter code here

PHP code won't work after adding html taggs

So I made PHP code that is used for signature, that is not problem right now the problem is that when I add <html></html> tags on the beginning of the code it won't show anything that I have done in PHP. So when I put html tags or make space in front of php there is nothing in page, but when I remove them everything work fine. I'm not expert in PHP so..
<?php
include_once("functions.php");
$sign = !isset($_GET['s']) ? 1 : $_GET['s'];
$uname = !isset($_GET["name"]) ? "None" : $_GET['name'];
// Connection & Website Settings
$ftpad = "";
$ftpuser = "";
$ftppass = "";
$comm = "SAMP";
$weburl = "www.incoming.com";
$usersdir = "/scriptfiles/Users";
//
$ftpcon = ftp_connect($ftpad,4112) or die("Error|I can't connect to the database: $ftpad, contact web master");
$login = ftp_login($ftpcon,$ftpuser,$ftppass);
$uname = "";
$name = $_GET['name'];
ftp_pasv($ftpcon,true);
$fhandle = fopen("tempsign_".hash('sha256',"$name").".tmp","w+");
ftp_fget($ftpcon,$fhandle,"$usersdir/$name.ini",FTP_ASCII);
$str = parse_ini_file2("tempsign_".hash('sha256',"$ime").".tmp");
fclose($fhandle);
$skin = $str['Skin'];
$rImg = ImageCreateFromPNG("./signs/1.png");
if (file_exists("./signs/skins/$skin.jpg"))
{
$skinImg = ImageCreateFromjpeg("./signs/skins/$skin.jpg");
}
else
{
$skinImg = ImageCreateFromjpeg("./signs/skins/0.jpg");
}
$cor_black = imagecolorallocate($rImg,0,0,0);
$cor_blue = imagecolorallocate($rImg,0,0,255);
$cor_lblue = imagecolorallocate($rImg,30,144,255);
$cor_green = imagecolorallocate($rImg,69,139,116);
$cor_red = imagecolorallocate($rImg,220,20,65);
$cor_wh = imagecolorallocate($rImg,255,255,255);
$cor_n = imagecolorallocate($rImg,246,74,14);
if(ftp_size($ftpcon,"$usersdir/$name.ini") == -1 || $ime == "None")
{
?>
<tr>
<center><td align="center" valign="top"><img src="logo.png" width="400" height="155" alt="logo" /></td></center>
</tr>
<style type="text/css">
body{
background-color:#000;
background-image:url(backg.png);
}
.
</style>
<?php
echo "<center><br/><br/><br/><br/><font color='#FF3333'>Error | That signature doesn't exist! Possible reasons:<br/><br/></font></center>";
echo "<center><font color='#0FB9FC'>1. You didn't enter your username in field for that<br/></font></center>";
echo "<center><font color='#0FB9FC'>2. You entered wrong username(Example Your_Name)<br/></font></center>";
echo "<center><font color='#0FB9FC'>3. Username that you entered isn't in our databse<br/></font></center>";
return 1;
}
else
{
ftp_pasv($ftpcon,true);
$fhandle = fopen("tempsign_".hash('sha256',"$name").".tmp","w+");
ftp_fget($ftpcon,$fhandle,"$usersdir/$name.ini",FTP_ASCII);
$str = parse_ini_file2("tempsign_".hash('sha256',"$name").".tmp");
fclose($fhandle);
imagettftext($rImg,12,0,11,39,$cor_n,"font.TTF",urldecode($name));
imagettftext($rImg,12,0,11,79,$cor_n,"font.TTF",urldecode($str['Level']));
imagettftext($rImg,12,0,173,120,$cor_n,"font.TTF",urldecode($str['Points']));
imagettftext($rImg,12,0,173,80,$cor_n,"font.TTF",urldecode($str['Hours']));
imagecopymerge($rImg, $skinImg, 308,6,0,0,80,100,100);
}
if($str['Sex'] == 0) { imagettftext($rImg,12,0,10,122,$cor_n,"font.TTF","Male"); }
else if($str['Sex'] == 1) { imagettftext($rImg,12,0,10,122,$cor_n,"font.TTF","Female"); }
if($str['GM'] > 0)
{
imagettftext($rImg, 13,0,5,161,$cor_green,"font.TTF","GameSupport");}
if($str['Admin'] > 0)
{
imagettftext($rImg, 13,0,5,161,$cor_red,"font.TTF","Admin");}
if($str['Leader'] > 0)
{
if($str['Leader'] == 1) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","LSPD"); }
else if($str['Leader'] == 2) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","FBI"); }
else if($str['Leader'] == 3) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","CNN"); }
else if($str['Leader'] == 4) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cocaina"); }
else if($str['Leader'] == 5) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cosa Nostra"); }
else if($str['Leader'] == 6) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Terror Squad Crew"); }
else if($str['Leader'] == 7) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","GSF"); }
else if($str['Leader'] == 8) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Yakuza"); }
else if($str['Leader'] == 9) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Russian Mafia"); }
else if($str['Leader'] == 10) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Underground Racers"); }
else if($str['Leader'] == 11) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Hitman Agency"); }
}
else if($str['Member'] > 0)
{
if($str['Member'] == 1) { imagettftext($rImg,13,0,171,40,$cor_wh,"font.TTF","LSPD"); }
else if($str['Member'] == 2) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","FBI"); }
else if($str['Member'] == 3) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","CNN"); }
else if($str['Member'] == 4) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cocaine"); }
else if($str['Member'] == 5) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cosa Nostra"); }
else if($str['Member'] == 6) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Terror Squad Crew"); }
else if($str['Member'] == 7) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","GSF"); }
else if($str['Member'] == 8) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Yakuza"); }
else if($str['Member'] == 9) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Russian Mafia"); }
else if($str['Member'] == 10) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Underground Racers"); }
else if($str['Member'] == 11) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Hitman Agency"); }
}
else
{
imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Civil");
}
ftp_close($ftpcon);
unset($str);
unset($ftpad);
unset($ftpuser);
unset($ftppass);
unset($ftpcon);
unset($login);
header('Content-type: image/png');
imagepng($rImg);
imagepng($skinImg);
?>
</style>
Please check your below code:
<?php
//Error reporting section
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once("functions.php");
$sign = !isset($_GET['s']) ? 1 : $_GET['s'];
$uname = !isset($_GET["name"]) ? "None" : $_GET['name'];
// Connection & Website Settings
$ftpad = "";
$ftpuser = "";
$ftppass = "";
$comm = "SAMP";
$weburl = "www.incoming.com";
$usersdir = "/scriptfiles/Users";
$ftpcon = ftp_connect($ftpad,4112) or die("Error|I can't connect to the database: $ftpad, contact web master");
$login = ftp_login($ftpcon,$ftpuser,$ftppass);
$uname = "";
$name = $_GET['name'];
ftp_pasv($ftpcon,true);
$fhandle = fopen("tempsign_".hash('sha256',"$name").".tmp","w+");
ftp_fget($ftpcon,$fhandle,"$usersdir/$name.ini",FTP_ASCII);
$str = parse_ini_file2("tempsign_".hash('sha256',"$ime").".tmp");
fclose($fhandle);
$skin = $str['Skin'];
$rImg = ImageCreateFromPNG("./signs/1.png");
if (file_exists("./signs/skins/$skin.jpg"))
{
$skinImg = ImageCreateFromjpeg("./signs/skins/$skin.jpg");
}
else
{
$skinImg = ImageCreateFromjpeg("./signs/skins/0.jpg");
}
$cor_black = imagecolorallocate($rImg,0,0,0);
$cor_blue = imagecolorallocate($rImg,0,0,255);
$cor_lblue = imagecolorallocate($rImg,30,144,255);
$cor_green = imagecolorallocate($rImg,69,139,116);
$cor_red = imagecolorallocate($rImg,220,20,65);
$cor_wh = imagecolorallocate($rImg,255,255,255);
$cor_n = imagecolorallocate($rImg,246,74,14);
if(ftp_size($ftpcon,"$usersdir/$name.ini") == -1 || $ime == "None")
{
?><tr>
<center><td align="center" valign="top"><img src="logo.png" width="400" height="155" alt="logo" /></td></center>
</tr>
<style type="text/css">
body{
background-color:#000;
background-image:url(backg.png);
}
</style><?php
echo "<center><br/><br/><br/><br/><font color='#FF3333'>Error | That signature doesn't exist! Possible reasons:<br/><br/></font></center>";
echo "<center><font color='#0FB9FC'>1. You didn't enter your username in field for that<br/></font></center>";
echo "<center><font color='#0FB9FC'>2. You entered wrong username(Example Your_Name)<br/></font></center>";
echo "<center><font color='#0FB9FC'>3. Username that you entered isn't in our databse<br/></font></center>";
return 1;
}
else
{
ftp_pasv($ftpcon,true);
$fhandle = fopen("tempsign_".hash('sha256',"$name").".tmp","w+");
ftp_fget($ftpcon,$fhandle,"$usersdir/$name.ini",FTP_ASCII);
$str = parse_ini_file2("tempsign_".hash('sha256',"$name").".tmp");
fclose($fhandle);
imagettftext($rImg,12,0,11,39,$cor_n,"font.TTF",urldecode($name));
imagettftext($rImg,12,0,11,79,$cor_n,"font.TTF",urldecode($str['Level']));
imagettftext($rImg,12,0,173,120,$cor_n,"font.TTF",urldecode($str['Points']));
imagettftext($rImg,12,0,173,80,$cor_n,"font.TTF",urldecode($str['Hours']));
imagecopymerge($rImg, $skinImg, 308,6,0,0,80,100,100);
}
if($str['Sex'] == 0) { imagettftext($rImg,12,0,10,122,$cor_n,"font.TTF","Male"); }
else if($str['Sex'] == 1) { imagettftext($rImg,12,0,10,122,$cor_n,"font.TTF","Female"); }
if($str['GM'] > 0){ imagettftext($rImg, 13,0,5,161,$cor_green,"font.TTF","GameSupport");}
if($str['Admin'] > 0){ imagettftext($rImg, 13,0,5,161,$cor_red,"font.TTF","Admin");}
if($str['Leader'] > 0){
if($str['Leader'] == 1) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","LSPD"); }
else if($str['Leader'] == 2) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","FBI"); }
else if($str['Leader'] == 3) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","CNN"); }
else if($str['Leader'] == 4) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cocaina"); }
else if($str['Leader'] == 5) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cosa Nostra"); }
else if($str['Leader'] == 6) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Terror Squad Crew"); }
else if($str['Leader'] == 7) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","GSF"); }
else if($str['Leader'] == 8) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Yakuza"); }
else if($str['Leader'] == 9) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Russian Mafia"); }
else if($str['Leader'] == 10) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Underground Racers"); }
else if($str['Leader'] == 11) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Hitman Agency"); }
}
else if($str['Member'] > 0)
{
if($str['Member'] == 1) { imagettftext($rImg,13,0,171,40,$cor_wh,"font.TTF","LSPD"); }
else if($str['Member'] == 2) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","FBI"); }
else if($str['Member'] == 3) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","CNN"); }
else if($str['Member'] == 4) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cocaine"); }
else if($str['Member'] == 5) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","La Cosa Nostra"); }
else if($str['Member'] == 6) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Terror Squad Crew"); }
else if($str['Member'] == 7) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","GSF"); }
else if($str['Member'] == 8) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Yakuza"); }
else if($str['Member'] == 9) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Russian Mafia"); }
else if($str['Member'] == 10) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Underground Racers"); }
else if($str['Member'] == 11) { imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Hitman Agency"); }
}
else
{
imagettftext($rImg,13,0,171,40,$cor_n,"font.TTF","Civil");
}
ftp_close($ftpcon);
unset($str);
unset($ftpad);
unset($ftpuser);
unset($ftppass);
unset($ftpcon);
unset($login);
header('Content-type: image/png');
imagepng($rImg);
imagepng($skinImg);
?>

Images created with PHP are not displayed

I am working to a banner generator. All code works perfectly if I access : banner.php?id=<ID>. I'm working on localhost so, I know, if I want to see this image that I've created, I must write:
<img src="http://localhost/banner.php?id=<ID>" />
I can see image ONLY if I access direct link. Why I can't see it if I add it into <img> tag? I thought is because I use cURL to get some variables, but no.
<?php
error_reporting(E_ALL);
include("settings.php");
// GET CULOURS
if(!isset($_GET['color_title'])) $color_title = "FFC200"; else $color_title = substr($_GET['color_title'],0,6);
if(!isset($_GET['color_info'])) $color_info = "FFFFFF"; else $color_info = substr($_GET['color_info'],0,6);
if(!isset($_GET['bg'])) $bg = "bg1"; else $bg = $_GET['bg'];
if(!isset($_GET['rank'])) $rank = "0"; else $rank = (int)$_GET['rank'];
// Get Userid
if(!$_GET['id'] || !ctype_digit($_GET['id'])){
echo '<meta http-equiv="refresh" content="0;url=index.html">';
}
$steamid = $_GET['id'];
// Get username, avatar , kills, deaths and played time
$noDigit = 0;
$hoursPlayed = 0;
$weHaveCSGO = 0;
$nullJson = 0;
if(ctype_digit($steamid)){
$noDigit = 1;
$uuser = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$steamauth['apikey']."&steamids=".$steamid."");
$user = json_decode($uuser, true);
// Until here
if(isset($user['response']['players'][0]['steamid'])){
$nullJson = 1;
$customURL = $user['response']['players'][0]['profileurl'];
$username = $user['response']['players'][0]['personaname'];
$avatar = $user['response']['players'][0]['avatarfull'];
$privacy = $user['response']['players'][0]['communityvisibilitystate'];
if($privacy == 3){
$getGames = simplexml_load_file($customURL."games?tab=all&xml=1");
foreach($getGames->games->game as $game){
if($game->appID == "730"){
$weHaveCSGO = 1;
$hoursPlayed = $game->hoursOnRecord;
}
}
$xml = simplexml_load_file($customURL."?xml=1");
$customMessage = $xml->stateMessage;
if($weHaveCSGO == 1){
$ggame = file_get_contents("http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=".$steamauth['apikey']."&steamid=".$steamid."");
$game = json_decode($ggame);
foreach($game->playerstats->stats as $stats){
if($stats->name == "total_kills"){ $total_kills = $stats->value ; }
else if($stats->name == "total_deaths"){ $total_deaths = $stats->value ; }
else if($stats->name == "last_match_favweapon_id"){ $last_match_weapon = $stats->value ; }
else if($stats->name == "total_rounds_played"){ $total_rounds_played = $stats->value; }
else if($stats->name == "total_wins"){ $total_wins = $stats->value; }
}
}
}
// Convert weaponID to weaponName
if($last_match_weapon == "1") { $last_match_favweapon = "Desert Eagle"; }
else if($last_match_weapon == "2") { $last_match_favweapon = "Dual Berettas"; }
else if($last_match_weapon == "3") { $last_match_favweapon = "Five-Seven"; }
else if($last_match_weapon == "7") { $last_match_favweapon = "AK-47"; }
else if($last_match_weapon == "4") { $last_match_favweapon = "Glock-18"; }
else if($last_match_weapon == "8") { $last_match_favweapon = "AUG"; }
else if($last_match_weapon == "9") { $last_match_favweapon = "AWP"; }
else if($last_match_weapon == "10") { $last_match_favweapon = "Famas"; }
else if($last_match_weapon == "11") { $last_match_favweapon = "G3SG1"; }
else if($last_match_weapon == "13") { $last_match_favweapon = "Galil AR"; }
else if($last_match_weapon == "14") { $last_match_favweapon = "M249"; }
else if($last_match_weapon == "16") { $last_match_favweapon = "M4"; }
else if($last_match_weapon == "17") { $last_match_favweapon = "Mac-10"; }
else if($last_match_weapon == "19") { $last_match_favweapon = "P90"; }
else if($last_match_weapon == "24") { $last_match_favweapon = "UMP-45"; }
else if($last_match_weapon == "25") { $last_match_favweapon = "XM1014"; }
else if($last_match_weapon == "26") { $last_match_favweapon = "PP-Bizon"; }
else if($last_match_weapon == "27") { $last_match_favweapon = "Mag-7"; }
else if($last_match_weapon == "28") { $last_match_favweapon = "Negev"; }
else if($last_match_weapon == "29") { $last_match_favweapon = "SawedOff"; }
else if($last_match_weapon == "30") { $last_match_favweapon = "Tec-9"; }
else if($last_match_weapon == "31") { $last_match_favweapon = "Zeus x27"; }
else if($last_match_weapon == "32") { $last_match_favweapon = "P2000"; }
else if($last_match_weapon == "33") { $last_match_favweapon = "MP7"; }
else if($last_match_weapon == "34") { $last_match_favweapon = "MP9"; }
else if($last_match_weapon == "35") { $last_match_favweapon = "Negev"; }
else if($last_match_weapon == "36") { $last_match_favweapon = "P250"; }
else if($last_match_weapon == "38") { $last_match_favweapon = "Scar-20"; }
else if($last_match_weapon == "39") { $last_match_favweapon = "SG553"; }
else if($last_match_weapon == "40") { $last_match_favweapon = "SSG08"; }
else if($last_match_weapon == "42") { $last_match_favweapon = "Knife"; }
else if($last_match_weapon == "43") { $last_match_favweapon = "Flashbang"; }
else if($last_match_weapon == "44") { $last_match_favweapon = "HE Grenade"; }
else if($last_match_weapon == "45") { $last_match_favweapon = "Smoke Grenade"; }
else if($last_match_weapon == "46") { $last_match_favweapon = "Molotov"; }
else if($last_match_weapon == "47") { $last_match_favweapon = "Decoy Grenade"; }
else if($last_match_weapon == "48") { $last_match_favweapon = "Incendiary Grenade"; }
else if($last_match_weapon == "49") { $last_match_favweapon = "C4"; }
else if($last_match_weapon == "59") { $last_match_favweapon = "Knife"; }
else if($last_match_weapon == "60") { $last_match_favweapon = "M4"; }
else if($last_match_weapon == "61") { $last_match_favweapon = "USP-S"; }
else if($last_match_weapon == "63") { $last_match_favweapon = "CZ75-Auto"; }
else { $last_match_favweapon = "Unknown"; }
}
// Create rank image
switch($rank){
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
$rank_image = "images/ranks/".$rank.".png";
break;
default:
$rank_image = "images/ranks/0.png";
break;
}
$rankimage = ImageCreateFromPNG($rank_image);
// Create banner
switch($bg){
case 'bg1':
case 'bg2':
case 'bg3':
case 'bg4':
$im = ImageCreateFromPNG("images/banners/$bg.png") or die ( 'GD Library not available atm.' );
break;
default:
$im = ImageCreateFromPNG("images/banners/bg1.png") or die ( 'GD Library not available atm.' );
break;
}
// Last match weaponID
$weapon = "images/weapons/hud/AK-47.png";
$lmweapon = ImageCreateFromPNG($weapon);
//Culours for text
$color_green = imagecolorallocate($im, 0, 183, 21);
$color_red = imagecolorallocate($im, 255, 0, 0);
$color_title = "0x$color_title";
$color_info = "0x$color_info";
$color_online = "0x24FF00";
$color_offline = "0xFF0000";
$color_black = "0x000000";
$color_bgreen = imagecolorallocate($im,0,160,0);
// Make some changes
$avatar = str_replace("https","http",$avatar);
// Get new sizes for avatar
list($width, $height) = getimagesize($avatar);
$newwidth = 90;
$newheight = 90;
// Load
$source = imagecreatefromjpeg($avatar);
// Lenght username
if(strlen($username) > 21){
$username = substr($username,0,21);
}
// Kills/Deaths Ratio
$kdr = #round($total_kills/$total_deaths,2);
// Win Ratio
$win = #round((($total_wins/$total_rounds_played)*100),2);
//Let's create image, but first check user
if($noDigit == 0 || $weHaveCSGO == 0 || $nullJson == 0){
imagettftext($im,20,0,140,60,$culoare_text_info,'fonts/arialbd.ttf',"This user doesn't exist !");
} else {
//Avatar
imagecopyresized($im, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Rank
imagecopy($im,$rankimage,96,5,0,0,imagesx($rankimage),imagesy($rankimage));
// Username
imagettftext($im,9,0,153,20,$color_info,'fonts/arialbd.ttf',$username);
// Status
$cauta = 'Last Online';
$cautare = strpos($customMessage, $cauta);
$cauta2 = 'In-Game<br/>Counter-Strike: Global Offensive';
$cautare2 = strpos($customMessage, $cauta2);
$cauta3 = 'In-Game<br/>';
$cautare3 = strpos($customMessage, $cauta3);
if($customMessage == "Online"){
imagettftext($im,9,90,347,63,$color_bgreen,'fonts/arialbd.ttf',"Online");
}elseif ($cautare !== false) {
imagettftext($im,7,0,290,20,$color_red,'fonts/arialbd.ttf',"Offline");
} elseif($cautare2 !== false){
imagettftext($im,7,0,282,20,$color_bgreen,'fonts/arialbd.ttf',"Playing CS:GO");
} elseif($cautare3 !== false){
imagettftext($im,7,0,276,20,$color_title,'fonts/arialbd.ttf',"IN OTHER GAME");
}
// Fav weapons from last match
imagecopy($im,$lmweapon,107,30,0,0,imagesx($lmweapon),imagesy($lmweapon));
imagettftext($im,9,0,110,70,$color_title,'fonts/arialbd.ttf',$last_match_favweapon);
// K/D Ratio
imagettftext($im,11,0,175,52,$color_info,'fonts/arialbd.ttf',$kdr);
imagettftext($im,9,0,177,70,$color_title,'fonts/arialbd.ttf',"K/D");
// Win RATIO
imagettftext($im,11,0,220,52,$color_info,'fonts/arialbd.ttf', $win."%");
imagettftext($im,9,0,222,70,$color_title,'fonts/arialbd.ttf',"WIN %");
// Hours Played
imagettftext($im,11,0,280,52,$color_info,'fonts/arialbd.ttf',$hoursPlayed."h");
imagettftext($im,9,0,282,70,$color_title,'fonts/arialbd.ttf',"TIME");
}
}
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
This section is wrong
<img src="http://localhost/banner.php?id=<ID>" />
It should be
<img src="http://localhost/path to your image" />
If you have done it for, onclick go to some page,
then it should be
<a href="http://localhost/banner.php?id=<ID>">
<img src="http://localhost/path to your image" />
</a>
Can you show us your code? Which graphics library do you use? I had no problems using GD2 on my local computer.
E.g.
<?php
header('Content-type: image/png');
$img = imagecreate(256, 256);
$background = imagecolorallocate($img, 255, 255, 0);
$color = imagecolorallocate($img, $_GET['red'], $_GET['blue'], $_GET['green']);
imagearc($img, 128, 128, 64, 64, 0, 0, $color);
imagepng($img);
?>
And in the HTML file then:
<img src="img.php?red=255&blue=0&green=0" />
Worked for me...
When i had changed file name "banner.php" to other name, ex: 'counter.php', ...
The same code is working fine. I don't know what's cause of file name with name = "banner" produced this error

How to Auto Login and Redirect After Registration in opencart

I am using opencart 2.0 and i have made custom registeration page in opencart.After successful registration i am redirecting to myaccount page but it will redirect to login page.
Can anybody help me in this to sort out the problem?
Here's my controller code :-
public function register() {
$this->load->language('checkout/checkout');
$json = array();
//if (!$json) {
$this->load->model('account/customer');
if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) {
$json['error']['firstname'] = $this->language->get('error_firstname');
}
/*if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) {
$json['error']['lastname'] = $this->language->get('error_lastname');
}*/
if ((utf8_strlen($this->request->post['email']) > 96) || !preg_match('/^(([^<>()[\]\\.,;:\s#\"]+(\.[^<>()[\]\\.,;:\s#\"]+)*)|(\".+\"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/', $this->request->post['email'])) {
$json['error']['email'] = $this->language->get('error_email');
}
if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$json['error']['warning'] = $this->language->get('error_exists');
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$json['error']['telephone'] = $this->language->get('error_telephone');
}
/*if ((utf8_strlen(trim($this->request->post['address_1'])) < 3) || (utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
$json['error']['address_1'] = $this->language->get('error_address_1');
}
if ((utf8_strlen(trim($this->request->post['city'])) < 2) || (utf8_strlen(trim($this->request->post['city'])) > 128)) {
$json['error']['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 2 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
if ($this->request->post['country_id'] == '') {
$json['error']['country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}*/
if ((utf8_strlen($this->request->post['password']) < 4) || (utf8_strlen($this->request->post['password']) > 20)) {
$json['error']['password'] = $this->language->get('error_password');
}
if ($this->request->post['confirm'] != $this->request->post['password']) {
$json['error']['confirm'] = $this->language->get('error_confirm');
}
/*if ($this->config->get('config_account_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id'));
if ($information_info && !isset($this->request->post['agree'])) {
$json['error']['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);
}
} */
// Customer Group
if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->post['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
// Custom field validation
$this->load->model('account/custom_field');
$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);
foreach ($custom_fields as $custom_field) {
if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) {
$json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
}
}
//}
//if (!$json) {
$customer_id = $this->model_account_customer->addCustomer($this->request->post);
// Clear any previous login attempts for unregistered accounts.
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
$this->session->data['account'] = 'register';
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
/*if ($customer_group_info && !$customer_group_info['approval']) {
$this->customer->login($this->request->post['email'], $this->request->post['password']);
// Default Payment Address
$this->load->model('account/address');
$this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
if (!empty($this->request->post['shipping_address'])) {
$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId());
}
} else {*/
$json['redirect'] = $this->url->link('account/account');
//}
unset($this->session->data['guest']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
// Add to activity log
$this->load->model('account/activity');
$activity_data = array(
'customer_id' => $customer_id,
'name' => $this->request->post['firstname'] . ' ' . $this->request->post['lastname']
);
$this->model_account_activity->addActivity('register', $activity_data);
//}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}

Parsing xml causes html to stop

This is inside an html document called rockwell.php. The php script works if $xmlData->checkerz[0]->attributes()->labro; when looping, but $xmlData->checkerz[$x]->attributes()->labro; prevents the rest of the html from loading when looping. Why would this looping parse conflict with everything below it in html?
<!DOCTYPE html>
<html lang="en">
...
<?php
header('Content-type: application/xml');
$privatecode = 'thisz';
$year = date("Y");
$month = date("n");
$day = date("d");
$url = 'api.php?private='.$privatecode.'&day='.$day.'&month='.$month.'&year='.$year;
$mis = file_get_contents($url);
$xmlData = simplexml_load_string($mis);
if (count($xmlData->checkerz) == 0) {
}
else {
for ($x = 0; $x <= 5; $x++) {
if ($x < count($xmlData->checkerz)) {
$timestampa = $xmlData->checkerz[$x]->attributes()->labro; //stops html here
$timestampb = $xmlData->checkerz[$x]->attributes()->day; //or here
$timestampc = $xmlData->checkerz[$x]->attributes()->month; //or here
$timestampd = $xmlData->checkerz[$x]->attributes()->year; //or here
if ($timestampc == '1') {
$timestampe = 'January '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '2') {
$timestampe = 'February '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '3') {
$timestampe = 'March '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '4') {
$timestampe = 'April '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '5') {
$timestampe = 'May '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '6') {
$timestampe = 'June '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '7') {
$timestampe = 'July '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '8') {
$timestampe = 'August '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '9') {
$timestampe = 'September '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '10') {
$timestampe = 'October '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '11') {
$timestampe = 'November '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else if ($timestampc == '12') {
$timestampe = 'December '.$timestampb.', '.$timestampa.'</br>';
echo $timestampe;
}
else {
}
}
}
}
?>
...
</html>
Because that is the way PHP works unless you do something to fork the process. Your script executes in a single execution thread which steps through your code one step at a time. Since the remaining HTML is after the loop it will not be rendered until the loop is complete.
Replacing this:
$timestampa = $xmlData->checkerz[$x]->attributes()->labro; //stops html here
$timestampb = $xmlData->checkerz[$x]->attributes()->day; //or here
$timestampc = $xmlData->checkerz[$x]->attributes()->month; //or here
$timestampd = $xmlData->checkerz[$x]->attributes()->year;
With this solved it:
if ($x == 0) {
$timestampa = $xmlData->checkerz[0]->attributes()-> labro;
$timestampb = $xmlData->checkerz[0]->attributes()->day;
$timestampc = $xmlData->checkerz[0]->attributes()->month;
$timestampd = $xmlData->checkerz[0]->attributes()->year;
}
else if ($x == 1) {
$timestampa = $xmlData->checkerz[1]->attributes()-> labro;
$timestampb = $xmlData->checkerz[1]->attributes()->day;
$timestampc = $xmlData->checkerz[1]->attributes()->month;
$timestampd = $xmlData->checkerz[1]->attributes()->year;
}
else if ($x == 2) {
$timestampa = $xmlData->checkerz[2]->attributes()-> labro;
$timestampb = $xmlData->checkerz[2]->attributes()->day;
$timestampc = $xmlData->checkerz[2]->attributes()->month;
$timestampd = $xmlData->checkerz[2]->attributes()->year;
}
else if ($x == 3) {
$timestampa = $xmlData->checkerz[3]->attributes()-> labro;
$timestampb = $xmlData->checkerz[3]->attributes()->day;
$timestampc = $xmlData->checkerz[3]->attributes()->month;
$timestampd = $xmlData->checkerz[3]->attributes()->year;
}
else if ($x == 4) {
$timestampa = $xmlData->checkerz[4]->attributes()-> labro;
$timestampb = $xmlData->checkerz[4]->attributes()->day;
$timestampc = $xmlData->checkerz[4]->attributes()->month;
$timestampd = $xmlData->checkerz[4]->attributes()->year;
}

Categories