Jump to content
Killersites Community

Search the Community

Showing results for tags 'php'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Entrepreneurship, Business and Marketing
    • Course: The Complete Entrepreneur
    • Social Media Marketing & Web Marketing
    • Entrepreneurship
    • Career Questions - Asked and Answered
  • Community Lounge and FAQ
    • Open Forum
    • New Members Forum - Start Here!
    • Forum Rules and Etiquette
    • Killersites Announcements
  • Web Design
    • Beginners Web Design
    • HTML/XHTML
    • CSS
    • Advanced Web Design
    • Business of Web Design
    • Web Design News
  • Software
    • StudioWeb
    • Dreamweaver
    • Photoshop
    • Miscellaneous Software
  • Programming
    • Python
    • Javascript
    • PHP
    • General Programming
    • Beginners Ruby
  • Miscellaneous
    • Cybersecurity
    • Blogs and CMS
    • Web Accessibility
    • Peer-to-Peer Reviews
    • Website Templates
    • Web Design Jobs
  • Archives
    • Beginners Web Design
    • Web Accessibility
    • CSS
    • Flash
    • ASP
    • Expression Web
    • Killersites University
    • Actionscript

Categories

There are no results to display.

Product Groups

  • Business & Entrepreneur Courses

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website


LinkedIn


Facebook


Twitter


AIM


Yahoo


Other


Location


Interests

Found 29 results

  1. Hi people! Since I couldnt get answers from Stackoverflow I desiced to ask you. Can someone explain how does these 2 functions work: class_exists() spl_autoload_register() Class exist function if(class_exists('User')){ echo "It does exists"; } class User { /* Some code here */ } // the output of file is "It does exists" So how does this function works? Scans whole file? Whole directory? I mean its called before I defined class. Spl autoload register function include 'functions.php'; // <- file where is the function class_exist('User') and spl_autoload_register() include 'db_config.php'; include 'database.php'; include 'user.php'; // <- Here is the class (User) So how does this function work? Its before any of those files that are included, and still it does it work? Does it scans whole directory where it is or what? I am really confused. Thanks peeps!
  2. Joseppi83

    PHP Login System

    So, I have followed the instructions to a 'T,' yet I get a notice after I update the password. I thought I might be missing something from the videos, so I cut what I typed out and copied and pasted the source code files for the video section in it, but the exact same notice rendered in the browser. Any idea what's up with the notice? Does it have to do with deprecated code from previous versions, since Ben's browser was not rendering the same notice? else { // insert into database if ($stmt = $mysqli->prepare("UPDATE members SET password = ? WHERE id = ?")) { $stmt->bind_param("ss", md5($input['pass'] . $config['salt']), $_SESSION['id']); $stmt->execute(); $stmt->close(); // add alert and clear form values $error['alert'] = 'Password updated successfully!'; $input['current_pass'] = ''; $input['pass'] = ''; $input['pass2'] = ''; // show form include('views/v_password.php'); } else { echo "ERROR: Could not prepare MySQLi statement."; } }
  3. Biske94

    Programing term

    What does mean that variable is set or not set? (in PHP or general) Does that means: // no var declared $var; $var = 'Some fancy string'; $var = ""; //(empty string) I dont know all fancy terms, but I do know when variable is defined, declared and all that, but I dont know what variable is set means. Thanks in advance, nerdz!
  4. lgc93

    PHP course on Ubuntu

    Hi everyone, I'm currently on Chapter 4 of the PHP course and I'm having problems following up everything since I'm using ubuntu linux instead of a mac or windows pc. As a result, I can't install MAMP and I've had to try a couple of alternatives (LAMP and XAMPP) but neither seem to be similar enough to the MAMP that Stef uses in his videos (LAMP doesn't seem to have a user interface at all and XAMPP doesn't have a simple user friendly UI like MAMP does, which allows you to search files , like Stef does in lesson 2 chapt. 4 in order to find php.ini). Is there a better MAMP alternative for ubuntu? Also, when I search my computer, I have 3 different php.ini files in the following directories: /opt/lampp/etc /etc/php/7.0/apache2 /etc/php/7.0/cli Which one of the three am I meant to modify so that I can enable error messages? All of them have restricted writing permissions ("You are not the owner so you cannot change these permissions"). Any advice will be appreciated. Thanks in advance.
  5. fana4

    booking system

    Hi there I've just started a fresh website for a non-profit organisation (meaning I won't get paid), so my options are: doing it as fast as possible, with minimum costs, standard interface, easy maintenance, strong community support. Therefore, being pragmatic, I've chosen WordPress (but i struggled finding out an appropriate free plugin... so I need to code it: PHP + mysqli). Now, this npo asked me for me a simple booking system for their training sessions. The business rules are: 1) several sessions available: A, B, C and D 2) A B C and D happen several times in a week 3) each user can book all 4, but can only book 1x (for the each session) 4) limit of seats per session: 20 5) total users : 100 (some will be left out, as soon as limit has been reached). 6) priority : FIFE (first in , first ENROLLED) 4) no payments involved My question is: which "tools" would you advise me? a ) create a new page OUT of WordPress with PHP? + mysqli? b ) create a new page OUT of WordPress with JAVASCRIPT? c ) create a new page WITH of WordPress with existing PLUGIN? nope, I couldn't find any suitable! d ) any other suggestion? Having done my research, many suggestions and recommendations show up...but I'd like your opinion according to your own experience. Txs
  6. Hi Thanks for the great tutorial! In medias res - just the way I like it. I thought I'd post questions as they come up, for a starter here's this: "Another convention is that getter and setter names should match the property names" Is this really just a convention or the class would not work at all otherwise? In other words do I need "var $name;" in order to set (and get) the value of "$this->name"?
  7. Aleksey

    Connecting MySQL with PHP

    A question about MySQL beginners course, part of connecting mysql with php, the video was very quickly and i didnt understand well. 1) Is there any simple way to connect a user to a database without such apps such cPanel? (from MyAdmin) 2)You told - "I am just using cPanel to connect a user with a database". Is there some free cPanel alternative that would work good on both mac and windows operating systems? For example i found some alternatives but on the download page i didnt see macos supported.
  8. I just started Beginners PHP course, when i use echo to display the result, it shows nothing. When i open beginners course file with forms it doesnt display echo on the screen as well. Can someone help me solve this problem?
  9. Biske94

    Whats the difference

    Hi i have encountered one quirk in PHP, and I was wandering if anyone can explain it to me. So writing this code gives me infinite loop public static function find_this_query($sql){ global $Database; $result_set = $Database->queryFunction($sql); $theObjectArray = array(); $var = $result_set->fetch_assoc(); // I put the whole array in $var while($row = $var){ // and then I put that here // some code here } return $theObjectArray; } Buuuut this doesnt public static function find_this_query($sql){ global $Database; $result_set = $Database->queryFunction($sql); $theObjectArray = array(); while($row = $result_set->fetch_assoc()){ // here I just put method and everything works fine // some code here } return $theObjectArray; } So I just wanna know why. Thanks nerdzzzz!
  10. PHP form --> convert to WP form Hi there, I have several (legacy) php forms I'd like to re-use in my wp site. No way I will retype them again... therefore I'm looking for a way to import them directly into wp. Would you recommend any plugin? I understand pasting the original php code into the text editor will save me a lot of time, but it won't be final, since a lot of validation has to be done, etc... Do you have any experience with importing php forms into wp with a kind of 1-click solution? WP's plugins repository is not obvious on this matter...or maybe I've just missed it. txs
  11. What is the difference between statements and functions? For instance why dont we type include('somefile.php') or echo('Hello World') ? Thanks!
  12. Biske94

    Isset function

    Okay this is a newbie question but I know how it works but I just want to know how. So this code for example: if(isset($_POST['submit'])){ // do some stuff } else { // do some else stuff } This if statement will only do its code block if submit button is clicked or in nerds language if $_POST['submit'] is set. So thats means that value of that submit button is NULL before clicking, but when we click that submit button we are giving it a value? For example <input type="submit" name="submit" value="someAwesomeValue"> if I click this button its value will be 'someAwesomeValue' which means I set $_POST['submit'] value to 'someAwesomeValue' or in other words $_POST['submit'] = 'someAwesomeValue' Thanks!
  13. Php Buddies, I'm going to jump into building my own searchengine now. Starting off with the search box, then the index and then finally the crawler. Not too worried about the crawler. Gonna make use of cURL and implode,explode, etc. php functions. It's the Index that I quite can't get my head around. To build the Index, should I have the structure of the mysql tbl like this .... ? Option 1 Columns Url|Keywords Or, should I make the structure like this instead ..... ? Option 2 Columns Keyword|Urls Option 1a Example Columns Url | Keywords ----------------------------------------------------------------------- devshed.com | forum, programming, php Option 1b Example Columns Keyword | Urls -------------------------------------------------------------------------------------------------------------------------- forum | devshed.com, blackhat.com, warriorforum.com --------------------------------------------------------------------------------------------------------------------------- php | devshed.com/forum/php.htm, sitepoint.com/forum/php.php Option 2a Example Columns Urls | Keyword ----------------------------------------------------------------------- devshed.com | forum ----------------------------------------------------------------------- devshed.com | programming ----------------------------------------------------------------------- warriorforum.com | money ----------------------------------------------------------------------- warriorforum.com | forum Option 2b Example Columns Keywords | Urls -------------------------------------------------------------------------------------------------------------------------- forum | devshed.com/forum -------------------------------------------------------------------------------------------------------------------------- forum | blackhat.com/forum --------------------------------------------------------------------------------------------------------------------------- php | devshed.com/forum/php.htm --------------------------------------------------------------------------------------------------------------------------- php | sitepoint.com/forum/php.php Question 1: I have a feeling you won't like Option 1a or 1b atall. But, let's assume you need to do it out of them 2 options. Which one would you choose ? Question 2: I have a feeling you will like Option 2a or 2b. Which one would you choose ? Or, if you don't like any of them 2. Then, let's assume you need to do it out of them 2 options. Which one would you choose ? Question 3: If you don't like the structure of any of the 4 options then which structure would you yourself use or have used ? Best to show an example like I did. Btw, I know that, if I structure my tbl around the way I showed in my examples then users would only be able to make queires for a single keyword and not a phrase. But, dealing with phrases get complicated and so for the time being, as a beginner, let's concentrate one thing at a time. Concentrate on the very first basic of indexing a url. Thanks
  14. Biske94

    mysqli_fetch_assoc in while loop

    Hi people, I have one question about mysqli_fetch_assoc in a while loop. $query = "SELECT * FROM category "; $result = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($result)) { $cat_id = $row['cat_id']; $cat_title = $row['cat_title']; echo $cat_id . " " . $cat_title ."<br>"; } So, how does $row = mysql_fetch_assoc($result) works? So it loops one row at a time from $results and stores that information in $row until it there is no row to return? And this mysqli_fetch_assoc($result) in while loop iterations is this " array(some rows that it got from $result) "? $row = mysqli_fetch_assoc($result) is same as $row = array(all rows from $result that are gathered by mysqli_fetch_assoc) ? And that means $row is actually an array, and every time it loops the information is not overwriten by new instead it is added? Sorry if i confused you with such questions Thanks in advance!
  15. Php Gurus, I built a registration.php but I know not why I see a blank page after clicking "Register" button. Ignore the <center> tag for the time being. Will replace that with <p align> tag. I put echoes on conditions to see which part of the conditions get triggered. But the echoes don't occur. And, out of the following 2, which one suits my context ? $row = mysqli_fetch_array($result, MYSQLI_ASSOC); // Use this line or next ? $row = mysqli_stmt_fetch($stmt); //Use this line or previous ? registration.php <?php /* ERROR HANDLING */ declare(strict_types=1); ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); include 'config.php'; //Step 1: Before registering User account, check if User is already registered or not. //Check if User is already logged-in or not. if (is_logged() === true) { die("You are already logged-in! No need to register again!"); } if ($_SERVER['REQUEST_METHOD'] == "POST") { //Step 2: Check User Submitted Details. //Check if user made all the required inputs or not. if (isset($_POST["username"]) && isset($_POST["password"]) && isset($_POST["password_confirmation"]) && isset($_POST["email"]) && isset($_POST["email_confirmation"]) && isset($_POST["first_name"]) && isset($_POST["surname"]) && isset($_POST["gender"])) { //Step 3: Check User details for matches against database. If no matches then validate inputs and register User account. //Create variables based on user inputs. $username = trim($_POST["username"]); $password = $_POST["password"]; $password_confirmation = $_POST["password_confirmation"]; $email = trim($_POST["email"]); $email_confirmation = trim($_POST["email_confirmation"]); $first_name = trim($_POST["first_name"]); $surname = trim($_POST["surname"]); $gender = $_POST["gender"]; $account_activation_code = sha1( (string) mt_rand(5, 30)); //Type Casted the INT to STRING on the 1st parameter of sha1 as it needs to be a STRING. $account_activation_link = "http://www.".$site_domain."/".$social_network_name."/activate_account.php? email=".$_POST['email']."&account_activation_code=".$account_activation_code.""; $account_activation_status = 0; // 1 = active; 0 = not active. $hashed_password = password_hash($password, PASSWORD_DEFAULT); //Encrypt the password. //Select Username and Email to check against Mysql DB if they are already registered or not. $stmt = mysqli_prepare($conn, "SELECT usernames, emails FROM users WHERE usernames = ? OR emails = ?"); mysqli_stmt_bind_param($stmt, 'ss', $username, $email); mysqli_stmt_execute($stmt); $result = mysqli_stmt_bind_result($stmt, $db_username, $db_email); //$row = mysqli_fetch_array($result, MYSQLI_ASSOC); // Use this line or next ? $row = mysqli_stmt_fetch($stmt); //Use this line or previous ? // Check if inputted Username is already registered or not. if ($row['usernames'] == $username) { $_SESSION['error'] = "That username is already registered."; exit(); // Check if inputted Username is between the required 8 to 30 characters long or not. } elseif (strlen($username) < 8 || strlen($username) > 30) { $_SESSION['error'] = "Username must be between 8 to 30 characters long!"; exit(); // Check if both inputted Emails match or not. } elseif ($email != $email_confirmation) { $_SESSION['error'] = "Emails don't match!"; exit(); // Check if inputed Email is valid or not. } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $_SESSION['error'] = "Invalid email! Insert your real Email in order for us to email you your account activation details."; exit(); // Check if inputted Email is already registered or not. } elseif ($row['emails'] == $email) { $_SESSION['error'] = "That email is already registered."; exit(); // Check if both inputted Passwords match or not. } elseif ($password != $password_confirmation) { $_SESSION['error'] = "Passwords don't match."; exit(); // Check if Password is between 8 to 30 characters long or not. } elseif (strlen($password) < 8 || strlen($password) > 30) { $_SESSION['error'] = "Password must be between 6 to 30 characters long!"; exit(); echo "line 88"; } else { //Insert the user's inputs into Mysql database using php's sql injection prevention method "Prepared Statements". $stmt = mysqli_prepare($conn, "INSERT INTO users(usernames, passwords, emails, first_names, surnames, genders, accounts_activations_codes, accounts_activations_statuses) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); mysqli_stmt_bind_param($stmt, 'sssssssi', $username, $hashed_password, $email, $first_name, $surname, $gender, $account_activation_code, $account_activation_status); mysqli_stmt_execute($stmt); echo "line 96"; //Check if user's registration data was successfully submitted or not. if (!$stmt) { $_SESSION['error'] = "Sorry! Our system is currently experiencing a problem registering your account! You may try registering some other time."; echo "line 102"; exit(); } else { echo "line 107"; //Email the account activation link for user to click it to confirm their email and activate their new account. $to = $email; $subject = "Your ".$site_name." account activation details!"; $body = nl2br(" ===============================\r\n ".$site_name." \r\n ===============================\r\n From: ".$site_admin_email."\r\n To: ".$email."\r\n Subject: Yours ".$subject." \r\n Message: ".$first_name." ".$surname."\r\n You need to click on this following <a href=".$account_activation_link.">link</a> to activate your account. \r\n"); $headers = "From: " . $site_admin_email . "\r\n"; if (!mail($to,$subject,$body,$headers)) { $_SESSION['error'] = "Sorry! We have failed to email you your account activation details. Please contact the website administrator!"; exit(); } else { echo "<h3 style='text-align:center'>Thank you for your registration!<br /> Check your email for details on how to activate your account which you just registered.</h3>"; exit(); } } } } } ?> <!DOCTYPE html> <html> <head> <title><?php $social_network_name ?> Signup Page</title> </head> <body> <div class ="container"> <?php // Error Messages. if (isset($_SESSION['error']) && !empty($_SESSION['error'])) { echo '<p style="color:red;">'.$_SESSION['error'].'</p>'; } ?> <?php //Session Messages. if (isset($_SESSION['message']) && !empty($_SESSION['message'])) { echo '<p style="color:red;">'.$_SESSION['error'].'</p>'; } ?> <?php //Clear Registration Session. function clear_registration_session() { //Clear the User Form inputs, Session Messages and Session Errors so they can no longer be used. unset($_SESSION['message']); unset($_SESSION['error']); unset($_POST); exit(); } ?> <form method="post" action=""> <center><h2>Signup Form</h2></center> <div class="form-group"> <center><label>Username:</label> <input type="text" placeholder="Enter a unique Username" name="username" required [A-Za-z0-9] value="<?php if(isset($_POST['username'])) { echo htmlentities($_POST['username']); }?>"> </center> </div> <div class="form-group"> <center><label>Password:</label> <input type="password" placeholder="Enter a new Password" name="password" required [A-Za-z0-9]></center> </div> <div class="form-group"> <center><label>Repeat Password:</label> <input type="password" placeholder="Repeat a new Password" name="password_confirmation" required [A-Za-z0-9]></center> </div> <div class="form-group"> <center><label>Email:</label> <input type="email" placeholder="Enter your Email" name="email" required [A-Za-z0-9] value="<?php if(isset($_POST['email'])) { echo htmlentities($_POST['email']); }?>"></center> </div> <div class="form-group"> <center><label>Repeat Email:</label> <input type="email" placeholder="Repeat your Email" name="email_confirmation" required [A-Za-z0-9] value="<?php if(isset($_POST['email_confirmation'])) { echo htmlentities($_POST['email_confirmation']); }?>"></center> </div> <div class="form-group"> <center><label>First Name:</label> <input type="text" placeholder="Enter your First Name" name="first_name" required [A-Za-z] value="<?php if(isset($_POST['first_name'])) { echo htmlentities($_POST['first_name']); }?>"></center> </div> <div class="form-group"> <center><label>Surname:</label> <input type="text" placeholder="Enter your Surname" name="surname" required [A-Za-z] value="<?php if(isset($_POST['surname'])) { echo htmlentities($_POST['surname']); }?>"></center> </div> <div class="form-group"> <center><label>Gender:</label> <input type="radio" name="gender" value="male" <?php if(isset($_POST['gender'])) { echo 'checked'; }?> required>Male<input type="radio" name="gender" value="female" <?php if(isset($_POST['gender'])) { echo 'checked'; }?> required>Female</center> </div> <center><button type="submit" class="btn btn-default" name="submit">Register!</button></center> <center><font color="red" size="3"><b>Already have an account ?</b><br> <a href="login.php">Login here!</a></font></center> </form> </div> </body> </html>
  16. Thoughts on introducing a Framework to an existing project that did not use any framework. Lets say I have a very big PHP / MySQL project. Client/Server application like some is OOP same is not, This application is a CRM system mostly for me to learn things, like oop, javascript, php7, jquery, sql, html5, css3. been using it for years and years So how would I go about introducing a framework? I wanna play with Laravel:) hehe My system is windows xampp... so it is all local. might create another copy of it using Laravel homestead virtual machine..again, just to learn it:D
  17. My PHP script for mysqli queries works most of the time, but while running a loop that queries database many times, occasionally I'll get Warning: PHP Warning: mysqli_stmt::execute(): (HY000/2013): Lost connection to MySQL server during query in... blah blah blah Can someone tell me if I need to modify the structure of my queries to make it work better? Here's my example: <?php $host = "localhost"; $username = "blah_blah"; $password = "blah_blah"; $database = "blah_blah"; $mysqli = new mysqli($host, $username, $password, $database,0,'/var/lib/mysql/mysql.sock'); $mysqli->set_charset('utf8'); if ($stmt = $mysqli->prepare("SELECT column_A FROM table_X WHERE column_B=? AND column_C=? LIMIT 1")){ $stmt->bind_param("si", $value_1, $value_2); $stmt->execute(); $stmt->bind_result($column_A_value); $stmt->fetch(); $stmt->close(); } ?>
  18. Hi, I am developing a php-mysql website hosted in an apache. The site is down since yesterday for my IP address, whereas it is visible elsewhere. The web hosting company said they do not see any problems and my IP is not blocked by them. The problem has occured before and was solved by itself after a few days. I simply do not understand the reason behind it. Annoying as I have to stop working on the site till it is restored. Please help. Cheers.
  19. scampbell70

    How Do I Style This?

    How do I style this table to make it look "prettier" I have tried a little with css and html tags with no luck. // display data in table echo "<table border='1' cellpadding='10'>"; echo "<tr> <th>ID</th> <th>First Name</th><th>Middle Name</th> <th>Last Name</th><th>Client ID</th><th>Diagnosis</th><th>Gender</th><th>Level of Care</th><th>Counselor</th><th>Active</th><th>Aftercare</th></tr>"; // loop through results of database query, displaying them in the table for ($i = $start; $i < $end; $i++) { // make sure that PHP doesn't try to show results that don't exist if ($i == $total_results) { break; } // find specific row $result->data_seek($i); $row = $result->fetch_row(); // echo out the contents of each row into a table echo "<tr>"; echo '<td>' . $row[0] . '</td>'; echo '<td>' . $row[3] . '</td>'; echo '<td>' . $row[1] . '</td>'; echo '<td>' . $row[2] . '</td>'; echo '<td>' . $row[4] . '</td>'; echo '<td>' . $row[5] . '</td>'; echo '<td>' . $row[7] . '</td>'; echo '<td>' . $row[10] . '</td>'; echo '<td>' . $row[11] . '</td>'; echo '<td>' . $row[15] . '</td>'; echo '<td>' . $row[18] . '</td>'; echo '<td><a href="records.php?id=' . $row[0] . '">Edit</a></td>'; echo '<td><a href="delete.php?id=' . $row[0] . '">Delete</a></td>'; echo "</tr>"; } // close table> echo "</table>";
  20. scampbell70

    Question About Check Boxes

    I have received so much help from this site and the amazing people on it. I am humbled by the amount of knowledge everyone here has. I am hoping that you can help me with something that I am struggling to figure out. I have a check box that successfully writes to my db but I can only get it to work with 1 and 0. I would like checked = yes unchecked to = no but I cant figure it out. Here is the code I am currently using. <strong>Active: *</strong> <input type="checkbox" name="Active" value="1" <?php if($Active == 1) echo 'checked="checked"'; ?>"/><br/> and $Active = (int)$_POST['Active'];
  21. Is it possible to have 2 or 3 tables in a database example Table 1 = names Table 2 = address Table 3 = phone numbers and when I fill in my name and number on a form it writes the name to the name table and number to the number table and then I can build a query to pull the phone that goes with the right name? Is it better to spilt it up this way for security or it doesn't really matter? I just feel like I have way to many rows in a single table on my database.
  22. scampbell70

    Return Total Number Of Records Found

    I am using the code from Basic PHP System: View, Edit, Add, Delete records with MySQLi and I am wanting to add some code that will display a total number of results returned from a query. if ($result = $mysqli->query("SELECT * FROM clients where (`clients`.`aftercare` = 'yes')ORDER BY LastName ASC")) My question is how can I display how many records are returned. So for example I run it and it returned 40 names. I would like to add something to the page that says 40 people found. I am sure this is probably very simple, but I am brand new to all of this. Thank you for you help in advance.
  23. Landslyde

    Pdo Conditional Select Statement

    Hello Forum: I'm just now trying to learn PHP and read that using PDO was a better way to utilize online databases. I have my Registration page completed, storing client info in a MySQL db, all done using PDO. However, I'm having a little trouble with the Login page. I don't know if I'm using the PDO stuff the right way. $stmt = $db->prepare('SELECT (username, password) FROM members WHERE (username) LIKE ? AND (password) LIKE ?'); $stmt->bindValue(1, "%$uname%", PDO::PARAM_STR); $stmt->bindValue(2, "%$pwd1%", PDO::PARAM_STR); $stmt->execute(); echo $affected_rows = $stmt->rowCount(); I'm not sure if I have the bindValue statements right, and I'm only assuming (hence the echo statement) that, if this is a valid username and password, one row will be affected. Like I said, I'm new to PHP, and this is my second day. So I imagine I have this code all wrong. Can someone set me on the right track? Much appreciated. ~Landslyde
  24. longki

    Ajax Pagination In Codeigniter

    Hello, i try to make an Ajax pagination, but I got error. Here is my code : Here is My Panel Controller : <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Panel extends MY_AuthController { public function __construct() { parent::__construct(); $this->load->model("paneldata"); } public function index() { $this->load->view('template/header/panel.php'); $this->load->view('containt/panel.php'); $this->load->view('template/footer/panel.php'); } public function general_post($awal = 0) { $this->load->library('pagination'); $this->load->model('paneldata'); $config['base_url'] = base_url() . '/panel/general_post'; $config['total_rows'] = $this->paneldata->jumlahpost(); $config['per_page'] = 3; $this->pagination->initialize($config); $data['link'] = $this->pagination->create_links(); $data['row'] = $this->paneldata->postview($awal); //Transkrip Script $this->load->view("section/post.php",$data); } //SOME CODE BELOW HERE } Here is my Panel View for header (template/header/panel.php): <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <?php echo link_tag('public/css/kickstart.css'); ?> <?php echo link_tag('public/css/kickstart.css'); ?> <?php echo link_tag('public/css/mine/panelstyle.css'); ?> <?php echo link_tag('public/css/mine/footer_acl.css'); ?> <?php echo '<script src="' . base_url() . 'public/js/jquery.min.js"></script>'?> <?php echo '<script src="' . base_url() . 'public/js/kickstart.js"></script>'?> <?php echo '<script src="' . base_url() . 'public/js/administration.js"></script>'?> </head> <body> And here is for content (containt/panel.php): <body> <div id="wrapper2"> <header id="logo" class="col_4"> <?php echo '<img src="' . base_url() . 'public/css/img/Logo2.png">'?> </header> <div id="tabcont" class="col_12"> <ul class="tabs left"> <li><a href="#tabr1">General</a></li> <li><a href="#tabr2">User</a></li> <li><a href="#tabr3">Gallery</a></li> <li><a href="#tabr4">Construction</a></li> </ul> <div id="tabr1" class="tab-content"> <div id="menu" class="col_3"> <ul class="menu vertical"> <li id="post"><a href="#">Post</a></li> <li id="events"><a href="#">Events</a></li> <li id="pages"><a href="#">Pages</a></li> <li id="user"><a href="#">User</a></li> <li><a href="#">Post</a></li> </ul> </div> <div id="content" class="col_9"> </div> </div> <div id="tabr2" class="tab-content">Tab2</div> <div id="tabr3" class="tab-content">Tab3</div> <div id="tabr4" class="tab-content"> <div id="menu" class="col_3"> <ul class="menu vertical"> <li id="post"><a href="#">Post</a></li> <li id="events"><a href="#">Events</a></li> <li id="pages"><a href="#">Pages</a></li> <li id="user"><a href="#">User</a></li> <li><a href="#">Post</a></li> </ul> </div> <div id="content" class="col_9"> </div> </div> </div> </div> Here is my javascript code for administration.js: $(document).ready(function() { /*UNTUK TABEL GENERAL*/ $('#tabr1 #content').load('panel/general_post'); $('#tabr4 #content').load('panel/construction_post'); $("#tabr1 #events").click(function(event){ $('#tabr1 #content').load('panel/general_event'); }); $("#tabr1 #post").click(function(event){ $('#tabr1 #content').load('panel/general_post'); }); $("#tabr1 #user").click(function(event){ $('#tabr1 #content').load('panel/general_user'); }); /*UNTUK TABEL CONSTRUCTION*/ $("#tabr4 #post").click(function(event){ $('#tabr4 #content').load('panel/construction_user'); }); /*UNTUK PAGINATION*/ $("#pagination a").click(function(event){ event.preventDefault(); /* get some values from elements on the page: */ //var $page = $( this ), // url = $page.attr( 'href' ); /* Send the data using post */ // var posting = load( url ); /* Alerts the results */ //posting.done(function( data ) { // alert("succes"); //$('#tabr1 #content').html(data); //}); alert('succes'); $('#isi').load('panel/general_user'); }); }); As you see, I use ajax to change the content of containt/panel.php. for example, if click at div#tabr1 #post, it will prevendefault and go to panel/general_post. After that, the content will change to section/post.php (because at function general_post on panel controller, it will load view section/post.php). Here is section/post.php : <!----><script type="text/javascript" src="http://localhost/2014/14_10_16_peduli_palu_ajax/public/js/jquery.min.js"></script> <script type="text/javascript" src="http://localhost/2014/14_10_16_peduli_palu_ajax/public/js/administration.js"></script> <!----> <a class="search" href="#">+ Advanced Search</a> <div style="clear:both"> </div> <a class="search" href="#"><i class="icon-refresh"></i> Refresh</a> <div style="clear:both"> </div> <div id="isi"> <table class="striped"> <tr> <td>Id</td> <td>Author</td> <td>Category</td> <td>Title</td> <td>Content</td> <td>Date Created</td> <td>Date Modified</td> <td>Action</td> </tr> <?php foreach($row as $r):;?> <tr> <td><?php echo $r->id; ?></td> <td><?php echo $r->author1; ?> <?php echo $r->author2; ?></td> <td><?php echo $r->category; ?></td> <td><?php echo $r->title; ?></td> <td><?php echo implode(' ', array_slice(explode(' ', $r->content), 0, 10)) . "..."; ?></td> <td><?php echo $r->date_created; ?></td> <td><?php echo $r->date_modified; ?></td> <td><a href="#"><i class="icon-edit"></i></a> <a href="facebook.com"><i class="icon-remove"></i></a></td> </tr> <?php endforeach; ?> </table> </div> <div id="pagination"> <?php echo $link; ?> </div> As you see in first and second line, I input the script. Why do i do this ? Because, section/post.php will not load any script in page, because section/post.php is just called by ajax (Look at admistration.js). But, if I do this, I got errors (I can't click <a> elements, I can't scroll the page, etc). And if i do not input the script (in first and second line on section/post.php), I can click the <a> elements, but the script is not worked (because section/post.php does not identify the script) What should I do ? I Hope you understand my question..
  25. Hi there, i have recieved this notice Warning: Header may not contain more than a single header, new line detected in C:\xampp\htdocs\a\Student_Edit_Handler.php on line 53 and these are my codes. Kindly help me to fix this. <?php session_start(); $session_id = $_SESSION['user_id']; if($session_id == null){ header("location:Student_Edit.php"); die(); } include 'Connect.php'; $flag = "success"; function rollbackData(){ mysql_query(" ROLLBACK "); global $flag; $flag = "error"; if(mysql_error() != null){ die(mysql_error()); } } $student_id = $_POST['student_id']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $gender = $_POST['gender']; $date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth'])); $contact_no = $_POST['contact_no']; $grade = $_POST['grade']; $section = $_POST['section']; $LRN = $_POST['LRN']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $address = $_POST['address']; $description = $_POST['description']; $imagename = ""; $flag= ""; mysql_query("SET AUTOCOMMIT = 0 "); if(mysql_error() != null){ die(mysql_error()); } $query = "UPDATE student_information SET first_name='$first_name',last_name='$last_name',"; $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',"; $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'"; $query .= " WHERE student_id='{$_SESSION['user_id']}'"; $result = mysql_query($query, $link_id); if(mysql_error() != null){ die(mysql_error()); } if($result) { $flag = "success"; } else { $flag = "error"; } header("location:Student_Edit.php?flag=$flag&student_id=student_id=$student_id"); ?> Please advise
×