Jump to content

saamde

New Members
  • Posts

    4
  • Joined

  • Last visited

saamde's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So I'm new to PHP GD, I cant understand why the PNG image will not go transparent, it's just showing a white background. Could anyone help me out with this? <?php $hour = date('H'); if ($hour > 4 && $hour < 12) { $image = "day.png"; } elseif ($hour > 11 && $hour < 19) { $image = "day.png"; } else { $image = "night.png"; } $image = imagecreatefrompng( "$image" ); if (!$image) { /* See if it failed */ header("(anti-spam-(anti-spam-content-type:)) $extList"); $im = imagecreatetruecolor (150, 30); /* Create a blank image */ $bgc = imagecolorallocate ($im, 255, 255, 200); $tc = imagecolorallocate ($im, 0, 0, 0); imagefilledrectangle ($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ imagestring ($im, 1, 5, 5, "Error loading Image", $tc); imagepng($im); imagedestroy($im); die(); } header("(anti-spam-(anti-spam-content-type:)) image/png"); imagepng($image); imagedestroy($image); ?> Thanks, Sam
  2. Hello, i'v been following a tut on how to make a register and login system and iv hit a brick wall... It won't display data.. This is my users.php <?php function user_data($user_id) { $data = array(); $user_id = (int)$user_id; $func_num_args = func_num_args(); $func_get_args = func_get_args(); if ($func_num_args > 1) { unset($func_get_args[0]); $fields = '`' . implode('`, `', $func_get_args) . '`'; $data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM `users` WHERE `user_id` = $user_id")); return $data; } } function logged_in() { return (isset($_SESSION['user_id'])) ? true : false; } function user_exists($username) { $username = sanitize ($username); (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'"), 0) == 1) ? true : false; } function user_active($username) { $username = sanitize ($username); return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `active` = 1"), 0) == 1) ? true : false; } function user_id_from_username($username) { $username = sanitize($username); return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `username` = '$username'"), 0, 'user_id'); } function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0) ==1) ? '$user_id' : false; } ?> and iv used this(see code) to get the user first name, Hello, <?php echo $user_data['first_name']; ?>! buts its showing like this...(see image) Help anyone? Thanks, Sam If you need to see some other code files, let me know and ill post.
  3. Hello! So iv almost finished my login page, when i went to test the page i'm getting this error. Heres my code for the login page. <?php include 'core/init.php';?> <!DOCTYPE html> <html lang="en"> <?php include 'includes/head.php';?> <body> <?php include 'includes/header.php'; ?> <div class="container"> <h2>Login</h2> <hr> <?php if (empty($_POST) === false) { $username = $_POST['username']; $password = $_POST['password']; if (empty($username) === true || empty($password) === true) { $errors[] = '<div class="alert alert-info"> You need to enter a username and password </div>'; } else if (user_exists($username) === false) { $errors[] = '<div class="alert alert-danger">We can\'t find that username. Have you registered?</div>'; } else if (user_active($username) === false) { $errors[] = '<div class="alert alert-warning">You haven\'t activated your account!</div>'; } else { $login = login($username, $password); if ($login === false) { $errors[] = '<div class="alert alert-info"> That username/password combination is incorrect. </div>'; } else { $_SESSION['user_id'] = $login; header('Location: index.php'); exit(); } } print_r($errors); } ?> <form action="login.php" method="post" class="form-horizontal" role="form"> <div class="form-group"> <label for="username" class="col-lg-1 control-label">Username:</label> <div class="col-lg-10"> <input name="username" type="username" class="form-control" id="username" placeholder="Username"> </div> </div> <div class="form-group"> <label for="Password" class="col-lg-1 control-label">Password:</label> <div class="col-lg-10"> <input name="password" type="password" class="form-control" id="password" placeholder="Password"> </div> </div> <div class="form-group"> <div class="col-lg-offset-1 col-lg-10"> <div class="checkbox"> <label> <input type="checkbox"> Remember me </label> </div> </div> </div> <div class="form-group"> <div class="col-lg-offset-1 col-lg-10"> <button type="submit" class="btn btn-default">Login</button> </div> <br> <div class="col-lg-offset-1 col-lg-10"> <a href="register.php">Register</a> </div> </div> </form> <div class="container"> <hr> <footer> <div class="row"> <div class="col-lg-12"> <p>Copyright © Company 2013</p> </div> </div> </footer> </div><!-- /.container --> <!-- Bootstrap core JavaScript --> <!-- Placed at the end of the document so the pages load faster --> <script src="js/jquery.js"></script> <script src="js/bootstrap.js"></script> <script src="js/modern-business.js"></script> </body> </html> Im kinda new to PHP and this is starting to baffle me...:/ Any Help would be muchly appreciated, thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.