PHP - Why Php Is Not Carrying Student Id From One Page To 2nd And Showing Student Id O
Hi All
I am kinda new to php.... I disparately need help with php coding. I am entering in the website using student id. If student id does not exist in mysql database, it gives me error. That works fine. But If I try to echo StudentID on 2nd page, it is not displaying anything. Second problem is I want to display student first and last name using StudentID. But it is not displaying anything using StudentID. Why? I have been trying to solve it, but no success Following is the code for both problems - if(!$db_selected) { die("Can not use".DB_NAME.':'.mysql_err()); } @$Stud_ID = $_POST['Stud_ID']; ?> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <link rel="stylesheet" type="text/css" href="ACSDP.css" /> <title>Student Main Page</title> <head><h1>Welcome to Undergraduate Student Main Page</h1> </head> <body> <form name ="mainpage" method='POST'> <table> <tr> <td><label id="Stud_ID2" for="Stud_ID"> Student ID <?php echo "is:" ." ". @$Stud_ID; ?> </label></td> <td> <label id="degree">Degree: Computer Science</label></td> </tr> <tr> <td> <label id="name"> Student Name: <?php $query2 =mysql_query("SELECT Stud_Lastname, Stud_Firstname FROM Student WHERE Stud_ID='$Stud_ID'") or die('wrong query'.mysql_error()); while($row = mysql_fetch_array($query2)) { echo $row['Stud_Lastname'] . " " . $row['Stud_Firstname']; } If have made those statements bold. please help me...... Similar TutorialsHi I get the following error when running this file. Fatal error: Call to undefined function mysqql_query() in C:\wamp\www\Isis\login.php on line 14] I'm not sure if i have missed something or typed something wrong but a second opinion is always better <?php $username = $_POST['username']; $password = $_POST['password']; $login = $_GET['login']; setcookie("username", "$username", time()+86400); if ($login=='yes') { $con = mysql_connect("localhost","root",""); mysql_select_db("obsosuser"); $get = mysqql_query("SELECT count(id) FROM obsosuser WHERE username='$username' and password='$password'"); if ($result!=1){ echo "Invalid Login!"; } else echo "Login Successful! Welcome back ".$_COOKIE['username']." Sir/Maddam." ; $_SESSION ['username'] = $username; } ?> Thanks I have a problem with login issue that when i loggin as student from index.php it should bring me to student_home php.. but it doesnt show anything and just bring me to index.php back.. i mixed up about header and session part..
index.php
<?php include('header.php'); //Start session session_start(); //Unset the variables stored in session unset($_SESSION['id']); ?> <body> <?php include('navhead.php'); ?> <div class="container"> <div class="row-fluid"> <div class="span3"> <div class="hero-unit-3"> <div class="alert-index alert-success"> <i class="icon-calendar icon-large"></i> <?php $Today = date('y:m:d'); $new = date('l, F d, Y', strtotime($Today)); echo $new; ?> </div> </div> <div class="hero-unit-1"> <ul class="nav nav-pills nav-stacked"> <li class="nav-header">Links</li> <li class="active"><a href="#"><i class="icon-home icon-large"></i> Home <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> <li><a href="sitemap.php"><i class="icon-sitemap icon-large"></i> Site Map <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> <li><a href="contact.php"><i class="icon-envelope-alt icon-large"></i> Contact Us <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a> </li> <li class="nav-header">About US</li> <li><a href="#mission" role="button" data-toggle="modal"><i class="icon-book icon-large"></i> Mission <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> <li><a href="#vision" role="button" data-toggle="modal"><i class="icon-book icon-large"></i> Vision <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> <li><a href="history.php"><i class="icon-list-alt icon-large"></i> History <div class="pull-right"> <i class="icon-double-angle-right icon-large"></i> </div> </a></li> </ul> </div> <br> </div> <div class="span9"> <section class="main"> <div class="custom-calendar-wrap"> <div id="custom-inner" class="custom-inner"> <div class="custom-header clearfix"> <nav> <span id="custom-prev" class="custom-prev"></span> <span id="custom-next" class="custom-next"></span> </nav> <h2 id="custom-month" class="custom-month"></h2> <h3 id="custom-year" class="custom-year"></h3> </div> <div id="calendar" class="fc-calendar-container"></div> </div> </div> </section> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Head Up!</strong> Welcome to Morpheus. </div> <div class="slider-wrapper theme-default"> <?php include('slider.php'); ?> </div> <!-- end slider --> </div> </div> </div> <!----------------> <div class="container"> <div class="row-fluid"> <div class="span12"> <div class="row-fluid"> <div class="span9"> <div class="alert alert-success"><i class="icon-file icon-large"></i> <strong>Mission</strong></div> <div class="hero-unit-2"> Announcements </div> </div> <div class="span3"> <div class="alert alert-info"> <i class="icon-building icon-large"></i> Faculty </div> <div class="hero-unit-3"> <p><a href=""><i class="icon-sign-blank"></i> Faculty</a></p> <p><a href=""><i class="icon-sign-blank"></i> Faculty</a></p> <p><a href=""><i class="icon-sign-blank"></i> Faculty</a></p> <p><a href=""><i class="icon-sign-blank"></i> Faculty</a></p> </div> </div> </div> </div> </div> <br> <div class="alert alert-success"><i class="icon-file icon-large"></i> <strong>Project</strong></div> <div class="hero-unit-2"> Project </div> <?php include('footer.php'); ?> </div> </body> </html>navhead.php <div class="row-fluid"> <div class="span12"> <div class="navbar navbar-fixed-top navbar-inverse"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-targer=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <div class="nav-collapse collapse"> <i class="icon-facebook-sign icon-large" id="color_white"></i> <i class="icon-twitter icon-large" id="color_white"></i> <i class="icon-google-plus icon-large" id="color_white"></i> <i class="icon-github-alt icon-large" id="color_white"></i> <i class="icon-linkedin-sign icon-large" id="color_white"></i> <div class="pull-right"> <form class="navbar-search pull-left"> <i class="icon-search icon-large" id="color_white"></i> <input type="text" class="search-query" placeholder="Search"> </form> </div> </div> </div> </div> </div> </div> </div> <div class="hero-unit-header"> <div class="container"> <div class="row-fluid"> <div class="span12"> <div class="row-fluid"> <div class="span6"> <img src="admin/images/head.png"> </div> <div class="span6"> <div class="pull-right"> <!--- login button --> <div class="btn-group"> <button class="btn btn-success"><i class="icon-signin icon-large"></i> Login</button> <button class="btn dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="#student" role="button" data-toggle="modal"><i class="icon-user icon-large"></i> Student</a></li> <li><a href="#teacher" role="button" data-toggle="modal"><i class="icon-user-md icon-large"></i> Teacher</a></li> </ul> </div> <!-- end login --> <?php include('student_modal.php'); ?> <?php include('teacher_modal.php'); ?> </div> </div> </div> </div> </div> </div> </div>student_modal.php <div id="student" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> </div> <div class="modal-body"> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Login Student!</strong> Please Enter the Details Below. </div> <form class="form-horizontal" method="post"> <div class="control-group"> <label class="control-label" for="inputEmail">Username</label> <div class="controls"> <input type="text" name="username" id="inputEmail" placeholder="Username"> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <input type="password" name="password" id="inputPassword" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" name="login" class="btn btn-info"><i class="icon-signin icon-large"></i> Sign in</button> </div> </div> <?php if (isset($_POST['login'])) { function clean($str) { $str = @trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $username = clean($_POST['username']); $password = clean($_POST['password']); $query = mysql_query("select * from student where username='$username' and password='$password'") or die(mysql_error()); $count = mysql_num_rows($query); $row = mysql_fetch_array($query); if ($count > 0) { session_start(); session_regenerate_id(); $_SESSION['id'] = $row['student_id']; header('location:student_home.php'); session_write_close(); exit(); } else { header('error_login.php'); ?> <?php } } ?> </form> <!-- teacher --> </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove-sign icon-large"></i> Close</button> </div> </div> login_student.php [php]<?php include('header.php'); //Start session session_start(); //Unset the variables stored in session unset($_SESSION['id']); ?> <body> <?php include('navhead.php'); ?> <div class="container"> <div class="row-fluid"> <div class="span10"> <ul class="breadcrumb"> <li class="active">Login<span class="divider">/</span></li> <li><a href="login_student.php"><i class="icon-group icon-large"></i> Teacher</a><span class="divider">/</span></li> <li class="active"><i class="icon-group icon-large"></i> Student</li> <div class="pull-right"> <li> <i class="icon-calendar icon-large"></i> <?php $Today = date('y:m:d'); $new = date('l, F d, Y', strtotime($Today)); echo $new; ?> </li> </div> </ul> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Login Student!</strong> Please Enter the Details Below. </div> <form class="form-horizontal" method="post"> <div class="control-group"> <label class="control-label" for="inputEmail">Username</label> <div class="controls"> <input type="text" name="username" id="inputEmail" placeholder="Username"> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <input type="password" name="password" id="inputPassword" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" name="login" class="btn btn-info"><i class="icon-signin"></i> Sign in</button> </div> </div> <?php if (isset($_POST['login'])) { function clean($str) { $str = @trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $username = clean($_POST['username']); $password = clean($_POST['password']); $query = mysql_query("select * from user where username='$username' and password='$password'") or die(mysql_error()); $count = mysql_num_rows($query); $row = mysql_fetch_array($query); if ($count > 0) { session_start(); session_regenerate_id(); $_SESSION['id'] = $row['user_id']; header('location:student_home.php'); session_write_close(); exit(); } else { session_write_close(); ?> <div class="pull-right"> <button type="button" class="close" data-dismiss="alert">×</button> <div class="alert alert-danger"><i class="icon-remove-sign"></i> Access Denied</div> </div> <?php exit(); } } ?> </form> </div> <div class="span2"> <div class="hero-unit-1"> <ul class="nav nav-pills nav-stacked"> <li class="nav-header">Links</li> <li><a href="index.php"><i class="icon-home icon-large"></i> Home</a></li> <li><a href="#"><i class="icon-file-alt icon-large"></i> New And Events</a></li> <li><a href="#"><i class="icon-sitemap icon-large"></i> Site Map</a></li> <li><a href="#"><i class="icon-envelope-alt icon-large"></i> Contact Us</a></li> <li class="nav-header">About US</li> <li><a href="#"><i class="icon-book icon-large"></i> Mission</a></li> <li><a href="#"><i class="icon-book icon-large"></i> Vision</a></li> <li><a href="#"><i class="icon-list-alt icon-large"></i> History</a></li> </ul> </div> </div> </div> <?php include('footer.php'); ?> </div> </body> </html>login_student.php <?php include('header.php'); //Start session session_start(); //Unset the variables stored in session unset($_SESSION['id']); ?> <body> <?php include('navhead.php'); ?> <div class="container"> <div class="row-fluid"> <div class="span10"> <ul class="breadcrumb"> <li class="active">Login<span class="divider">/</span></li> <li><a href="login_student.php"><i class="icon-group icon-large"></i> Teacher</a><span class="divider">/</span></li> <li class="active"><i class="icon-group icon-large"></i> Student</li> <div class="pull-right"> <li> <i class="icon-calendar icon-large"></i> <?php $Today = date('y:m:d'); $new = date('l, F d, Y', strtotime($Today)); echo $new; ?> </li> </div> </ul> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Login Student!</strong> Please Enter the Details Below. </div> <form class="form-horizontal" method="post"> <div class="control-group"> <label class="control-label" for="inputEmail">Username</label> <div class="controls"> <input type="text" name="username" id="inputEmail" placeholder="Username"> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <input type="password" name="password" id="inputPassword" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" name="login" class="btn btn-info"><i class="icon-signin"></i> Sign in</button> </div> </div> <?php if (isset($_POST['login'])) { function clean($str) { $str = @trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $username = clean($_POST['username']); $password = clean($_POST['password']); $query = mysql_query("select * from user where username='$username' and password='$password'") or die(mysql_error()); $count = mysql_num_rows($query); $row = mysql_fetch_array($query); if ($count > 0) { session_start(); session_regenerate_id(); $_SESSION['id'] = $row['user_id']; header('location:student_home.php'); session_write_close(); exit(); } else { session_write_close(); ?> <div class="pull-right"> <button type="button" class="close" data-dismiss="alert">×</button> <div class="alert alert-danger"><i class="icon-remove-sign"></i> Access Denied</div> </div> <?php exit(); } } ?> </form> </div> <div class="span2"> <div class="hero-unit-1"> <ul class="nav nav-pills nav-stacked"> <li class="nav-header">Links</li> <li><a href="index.php"><i class="icon-home icon-large"></i> Home</a></li> <li><a href="#"><i class="icon-file-alt icon-large"></i> New And Events</a></li> <li><a href="#"><i class="icon-sitemap icon-large"></i> Site Map</a></li> <li><a href="#"><i class="icon-envelope-alt icon-large"></i> Contact Us</a></li> <li class="nav-header">About US</li> <li><a href="#"><i class="icon-book icon-large"></i> Mission</a></li> <li><a href="#"><i class="icon-book icon-large"></i> Vision</a></li> <li><a href="#"><i class="icon-list-alt icon-large"></i> History</a></li> </ul> </div> </div> </div> <?php include('footer.php'); ?> </div> </body> </html> I have a small database snippet over at SQLFiddle: http://sqlfiddle.com/#!2/9ff722/55
I need help with writing a query that will allow me to track students in a certain cohort from beginning to graduation. I have two tables: application and stu_acad_cred. The application has the start term and the stu_acad_cred are course registrations. If I want to track students in a fall 2012 (12/FA) cohort, then the query must join the two tables; if the student has a start term of 12/FA *and* has registered for 12/FA courses, the student should be counted. I then want to track those student from year to year or term to term to see if the number of students that started in the 12/FA cohort actually decrease overtime. So, the results should return something similar to below.
| # Students (12/FA Cohort) | Year | ------------------------------------- | 2 | 2012 | | 2 | 2013 | | 2 | 2014 |I am not sure if this can be done straight forward or with a stored procedure but any help or direction is greatly appreciated. Hi All
I am having problems running a query to get the courses a student is enrolled for.
The format I need is somthing like this:
firstname - lastname - course ------------------------------------------- Joe Bloke US232456 Joe Bloke US554665 Joe Bloke US332098or like this firstname - lastname - course ------------------------------------------------- Joe Bloke US232456 US554665 US332098The query I am running is SELECT usr.firstname, usr.lastname, c.shortname FROM mdl_course c INNER JOIN mdl_context cx ON c.id = cx.instanceid AND cx.contextlevel = '50' INNER JOIN mdl_role_assignments ra ON cx.id = ra.contextid INNER JOIN mdl_role r ON ra.roleid = r.id INNER JOIN mdl_user usr ON ra.userid = usr.id WHERE r.name = 'Learner' AND usr.firstname = 'G01 Moloko' ORDER BY usr.firstname, c.shortnameThe problem is that I know this student is enrolled for 3 courses, but it only returns 1 course. Any help is welcomed. huck Hello sir, My name is Soji. I'm working on a php project on result transcript processing. I got to a stage where i need to rank student based on their score (Subject Position) and also Overall Position. I have tried all i could but i still don't get it I have a table called Subject position where with field (id, studentregNo, subjectid, levelid, armsid, yearid, total). what i want is if there is 3 student in a class and the first student score 50 in english and the second student score 45 and the third score 40. i want the system to tell me that the first student position in English is 1st and the second student position in English is 2nd and third student position in English is 3rd. So all this will be applicable to all subjects that the students in a particular level are offering.
Moreover, I need Rank student in a subject in that class, And this will work with each subject for each student in that class. I have mysql table titled fee_payment.
details of the table:
fee_payment Table
payment_id student_id name class term year date amount
1 6 john JHS2 2nd_term 2013 23-04-2013 56 67
2 6 john JHS2 2nd_term 2013 23-04-2013 56 34
3 5 peter JHS3 3rd_term 2014 23-04-2014 56 85
4 6 john JHS2 2nd_term 2014 23-04-2014 56 76
5 6 john JHS2 3rd_term 2014 23-04-2014 56 34
6 6 john JHS2 2nd_term 2014 23-04-2014 56 23
7 5 peter JHS2 3rd_term 2014 23-04-2014 56 43
what i need to do now is to sum total amount paid by each student so that i can view payment records based on term and year.
what i have tried:
Controller:
/******MANAGE FEE PAYMENTS / INVOICES WITH STATUS*****/ function payfees($param1 = '', $param2 = '', $param3 = '') { if ($this->session->userdata('admin_login') != 1) redirect(base_url(), 'refresh'); if ($param1 == 'create') { $data['student_id'] = $this->input->post('student_id'); $data['name'] = $this->input->post('name'); $data['class_id'] = $this->input->post('class'); $data['term'] = $this->input->post('term'); $data['year'] = $this->input->post('year'); $data['amount'] = $this->input->post('amount'); $data['creation_timestamp'] = strtotime($this->input->post('date')); $this->db->insert('fee_payment', $data); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } if ($param1 == 'do_update') { $data['student_id'] = $this->input->post('student_id'); $data['class_id'] = $this->input->post('class'); $data['term'] = $this->input->post('term'); $data['year'] = $this->input->post('year'); $data['amount'] = $this->input->post('amount'); $data['creation_timestamp'] = strtotime($this->input->post('date')); $this->db->where('payment_id', $param2); $this->db->update('fee_payment', $data); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } else if ($param1 == 'edit') { $page_data['edit_data'] = $this->db->get_where('fee_payment', array( 'payment_id' => $param2 ))->result_array(); } if ($param1 == 'delete') { $this->db->where('payment_id', $param2); $this->db->delete('fee_payment'); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } $page_data['page_name'] = 'payfees'; $page_data['page_title'] = get_phrase('fee_payment'); $this->db->order_by('creation_timestamp', 'term'); $page_data['payments'] = $this->db->get('fee_payment')->result_array(); $this->load->view('index', $page_data); } The Invoice: <div class="box-content"> <?php foreach($edit_data as $row):?> <div class="pull-left"> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('payment_to');?> <img width="50" height="30" src="<?php echo base_url();?>uploads/logo.png" style="max-height:100px;margin:20px 0px;" /> </span> <br /> <?php echo $system_name;?> <br /> <?php echo $this->db->get_where('settings' , array('type'=>'address'))->row()->description;?> </div> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('credited_account:');?> </span> <br /> <?php echo $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->name;?> <br /> <?php echo get_phrase('student_id');?> : <?php echo "FAVECSID0000", $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->student_id;?> <br /> <?php echo get_phrase('class');?> : <?php $class_id = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->class_id; echo $this->db->get_where('class' , array('class_id'=>$class_id))->row()->name; ?> </div> <div style="clear:both;"></div> <hr /> <table width="100%" background="http://localhost/sch...backlogos.png"> <tr style="background-color:#7087A3; color:#fff; padding:5px;"> <td style="padding:5px;"><?php echo get_phrase('payment_details');?></td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <?php echo get_phrase('amount');?> </div> </td> </tr> <tr> <td> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('payment_made');?> </span> <br /> </td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php echo "Gh", $row['amount'];?> </span> </div> </td> </tr> <tr> <tr> <td> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('balance');?> </span> <br /> <?php echo $row['description'];?> <?php $exams = $this->db->get_where('fee_payment', array('student_id'=>$row['student_id']))->result_array(); foreach($exams as $row): ?> <?php $ttpaid = sum($row['amount']); echo $ttpaid;?> <?php endforeach; ?> </td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php $tuition = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->tuition_fee; $status = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->status_fee; $total_fees = $tuition + $status; $balance_fee = $total_fees - $row['amount']; echo "Gh", $balance_fee; ?> </span> </div> </td> </tr> <tr> <td></td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <hr /> <?php echo get_phrase('status');?> : <?php echo $row['status'];?> <br /> <?php echo get_phrase('receipt_no:');?> : <?php echo "FAVECSFP0000",$row['payment_id'];?> <br /> <?php echo get_phrase('date');?> : <?php echo date('m/d/Y', $row['creation_timestamp']);?> </div> </td> </tr> </table> <br /> <br /> <?php endforeach;?> </div> </div> output: ayment To fffff P O BOX 126 Credited Account: john Student Id : FAVECSID00006 Class : JHS2A I am pretty new to PHP and am trying to create a simple (so I assumed) page to takes data from one html page(works fine) and updates a MYSQL Database. I am getting no error message, but the connect string down to the end of the body section is showing up as plain text in my browser window. I do not know how to correct this. I have tried using two different types of connect strings and have verified my names from the HTML page are the same as listed within the php page. Suggestions on what I need to look for to correct would be great. I have looked online, but so far all I am getting is how to connect, or how to create a comment, so I thought I would try here. Thank you for any assistance I may get!! - Amy - Code: [Select] <body><font color="006600"> <div style="background-color:#f9f9dd;"> <fieldset> <h1>Asset Entry Results</h1> <?php // create short variable names $tag=$_POST['tag']; $serial=$_POST['serial']; $category=$_POST['category']; $status=$_POST['status']; $branch=$_POST['branch']; $comments=$_POST['comments']; if (!$tag || !$serial || !$category || !$status || !$branch) { echo "You have not entered all the required details.<br />" ."Please go back and try again."; exit; } if (!get_magic_quotes_gpc()) { $tag = addslashes($tag); $serial = addslashes($serial); $category = addslashes($category); $status = addslashes($status); $branch = addslashes($branch); $comments = addslashes($comments); } //@ $db = new mysqli('localhost', 'id', 'pw', 'inventory'); $db = DBI->connect("dbi:mysql:inventory:localhost","id","pw") or die("couldnt connect to database"); $query = "insert into assets values ('".$serial."', '".$tag."', '".$branch."', '".$status."', '".$category."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." asset inserted into Inventory."; } else { echo "An error has occurred. The item was not added."; } $db->close(); ?> </fieldset> </div> </body> Hey guys, please tell me why the session var $_SESSION['return_url'] is not carrying from test.php to login.php The two echos in this file work perfectly, so i know the session var is registered... test.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>SWG:ANH • Bringing PreCU back to life...</title> <link rel="shortcut icon" href="favicon.ico" /> <link rel="stylesheet" type="text/css" media="screen" href="theme/main.css" /> <?php session_start(); // This section will generate a var containing the current page URL. This will be used to allow the language script to redirect users back to the page they // were on, in the language they selected. It is registered as a session variuable that will change every time the page changes. function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } // Here we register the URL we grabbed earlier in the session var. $return_url = curPageURL(); $_SESSION['return_url'] = $return_url; echo $_SESSION['return_url']; echo $return_url; include 'lang/enus.php'; include 'menu.php'; ?> login.php <?php session_start(); echo $_SESSION['return_url'] ; include 'dbconnect.php'; $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $return_url = $_SESSION['return_url']; echo $return_url; $result = mysql_query("SELECT COUNT(*) FROM account WHERE Username='$username' and Pass='$password'") or die(mysql_error()); $result = mysql_fetch_row($result); $result = $result[0]; if($result == 1){ $_SESSION['username'] = $username; header("Location:".$return_url); } else { echo "Wrong Username or Password. Use the back button. If you think this message is incorrect, contact the webmaster."; } ?> I know its not carrying because the echo in login.php is not returning anything and the script cant execute the header function because it has nowhere to go! Ive narrowed it down to the session var not carrying. Hi, I'm having trouble carrying items between two files. The problem is that it works too well. Whenever I include a php file that echos something, the other php files echos the same thing. What are some ways to stop this, but still have access to the variable. Thanks, GEORGE Hi I've got a form that users enter an identification pin in for their first question as well as clicking a radio button(Q1.php) . They click submit and the answers are put through a couple of multiplication function and then placed in a table (alongside the pin) via Q2.php. On the Q2 page I want to place the 2nd question that the user needs to answer. Rather than making them retype the pin I was hoping to process it as a hidden field - being picked up from their Q1.php entry. This 'hidden pin echo ' process will continue throughout Q2- Q10 pages. However - I can't seem to include any php in the page after the Q1 form has been processed. Have I got my php tags messed up? <?php $con = mysql_connect("localhost","ca","d"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("candango", $con); $q1 =$_POST['q1']; $pin =$_POST['pin']; $ans1 = $q1 * 3; $ans2 = $q1 * 5; $ans3 = $q1 * 2; $enter_sql= "INSERT INTO aapcm2 (pin,ans1, ans2, ans3) VALUES ('$pin','$ans1','$ans2','$ans3')"; $enter_query =mysql_query($enter_sql) or die (mysql_error()); ?> <body> <p>Thank you - You have successfully entered your answers.</p><form action="q2.php" method="post"> <p>What do you think the answer to this one is? <input type="radio" name="q2" id="q2" value="-3"> <label for="q2"></label> <input name="Hidden" type="hidden" id="Hidden" value="$pin" /></p> <p> <input type="submit" name="button" id="button" value="Submit"> </p> </form> <p></p> </body> Hey all, Been coding another script for my website which allows me to update a users Rank, allthough, when I try and view the page its giving me a White Blank Page. I carn't accually see whats wrong in my Script... <?php session_start(); include ("../includes/config.php"); include ("../includes/function.php"); logincheck(); ini_set ('display_errors', 1); error_reporting (E_ALL); $username = $_SESSION['username']; // Owner Script - Change Users Rank $userlevel = mysql_query ("SELECT * FROM users WHERE username = '$username' LIMIT 1") or die ("Error Finding Right Users " . mysql_error()); $levelright = mysql_fetch_object($userlevel); // If userlevel isn't 5, move them on... if ($levelright->userlevel == "1" || $levelright->userlevel == "2" || $levelright->userlevel == "3" || $levelright->userlevel == "4"){ header ("Location: 404.php"); die(); } // Start Change Rank... if (strip_tags($_POST['changerank'])){ $name = $_POST['name']; $userchange = $_POST['userchange']; $real = mysql_query ("SELECT * FROM users WHERE username = '$userchange' LIMIT 1"); $number = mysql_num_rows($real); if ($number != "1"){ echo ("$userchange, is NOT registered! - Simple Words : No Such User!"); } if ($name == 1){ $reprand = rand(100, 50000); mysql_query ("UPDATE users SET rank = 'Learner Driver (1)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 1 if ($name == 2){ $reprand = rand(50000, 200000); mysql_query ("UPDATE users SET rank = 'Passed Driver (2)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 2 if ($name == 3){ $reprand = rand(200000, 500000); mysql_query ("UPDATE users SET rank = 'New Driver (3)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 3 if ($name == 4){ $reprand = rand(500000, 2500000); mysql_query ("UPDATE users SET rank = 'Speeding Driver (4)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 4 if ($name == 5){ $reprand = rand(2500000, 7000000); mysql_query ("UPDATE users SET rank = 'Skilled Driver (5)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 5 if ($name == 6){ $reprand = rand(7000000, 20000000); mysql_query ("UPDATE users SET rank = 'Maniac Driver (6)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 6 if ($name == 7){ $reprand = rand(20000000, 45000000); mysql_query ("UPDATE users SET rank = 'Wanted Racer (7)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 7 if ($name == 8){ $reprand = rand(45000000, 90000000); mysql_query ("UPDATE users SET rank = 'Pro Driver (8)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 8 if ($name == 9){ $reprand = rand(90000000, 115000000); mysql_query ("UPDATE users SET rank = 'Supreme Racer (9)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 9 if ($name == 10){ $reprand = rand(115000000, 150000000); mysql_query ("UPDATE users SET rank = 'Super Supreme Racer (10)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 10 if ($name == 11){ $reprand = rand(150000000, 210000000); mysql_query ("UPDATE users SET rank = 'Show Off Driver (11)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 11 if ($name == 12){ $reprand = rand(210000000, 280000000); mysql_query ("UPDATE users SET rank = 'Extreme Show Off Driver (12)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 12 if ($name == 13){ $reprand = rand(280000000, 350000000); mysql_query ("UPDATE users SET rank = 'Trained Driver (13)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 13 if ($name == 14){ $reprand = rand(350000000, 430000000); mysql_query ("UPDATE users SET rank = 'Super Trained Driver (14)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 13 if ($name == 15){ $reprand = rand(430000000, 520000000); mysql_query ("UPDATE users SET rank = 'Legendry Racer (15)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 15 if ($name == 16){ $reprand = rand(520000000, 600000000); mysql_query ("UPDATE users SET rank = 'Most Legendry Racer (16)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 16 if ($name == 17){ $reprand = rand(600000000, 1000000000); mysql_query ("UPDATE users SET rank = 'Official SD Legend (17)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 17 if ($name == 18){ $reprand = rand(1000000000, 1000000010); mysql_query ("UPDATE users SET rank = 'Hidden Rank! (18)' AND rep = '$reprand' WHERE username = '$userchange'") or die ("Error Updating rank " . mysql_error()); } // Name 18 echo ("Successfully updated $userchange Rank!"); mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$userchange', 'System', 'Your Rank has now been changed!', '$date', '0', '0', '0')") or die ("Error updating there inbox!" . mysql_error()); } // Rank Change if (strip_tags($_POST['selectname'])){ $writenname = $_POST['nameinput']; $rankinput = $_POST['rankinput']; $repinput = $_POST['repinput']; $findme = mysql_query ("SELECT * FROM users WHERE username = '$writenname' LIMIT 1") or die ("Error Searching Names " . mysql_error()); $found = mysql_num_rows($findme); if ($found != "1"){ echo ("$writenname, isn't Registered! - Simple Terms : No Such User"); }else{ mysql_query ("UPDATE users SET rank = '$rankinput' AND rep = '$repinput' WHERE username= '$writenname'") or die ("Error Updating Rank + Rep " . mysql_error()); echo ("$writenname Rank has now been changed!"); mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` ) VALUES ( '', '$writenname', 'System', 'Your Rank has now been changed!', '$date', '0', '0', '0')") or die ("Error updating there inbox!" . mysql_error()); } // Found? } // Post selectname ?> <html> <head> <title>Change Users Rank</title> </head> <body class='body'> <form action='' method='POST' name='Change Rank'> <table width='40%' border='1' cellpadding='0' cellspacing='0' class='table' align='center'> <tr> <td class='header' align='center' colspan='2'>Change Users Rank?</td> </tr> <tr> <td class='omg' align='center'>This will change the users Current Rank!</td> </tr> <tr> <td align='right'>Username:</td><td><input type='text' name='userchange' class='input'></td> </tr> <tr> <td><select name='name' size='1' class='dropbox'> <option value="1">Learner Driver (1)</option> <option value="2">Passed Driver (2)</option> <option value="3">New Driver (3)</option> <option value="4">Speeding Driver (4)</option> <option value="5">Skilled Driver (5)</option> <option value="6">Maniac Driver (6)</option> <option value="7">Wanted Racer (7)</option> <option value="8">Pro Driver (8)</option> <option value="9">Supreme Racer (9)</option> <option value="10">Super Supreme Racer (10)</option> <option value="11">Show Off Driver (11)</option> <option value="12">Extreme Show Off Driver (12)</option> <option value="13">Trained Driver (13)</option> <option value="14">Super Trained Driver (14)</option> <option value="15">Legendry Racer (15)</option> <option value="16">Most Legendry Racer (16)</option> <option value="17">Official SD Legend (17)</option> <option value="18">Hidden Rank! (18)</option></td> </tr> <tr> <td class='omg' align='center' colspan='2'><input type='submit' name='changerank' class='button'></td> </tr> </table> <br /> <table width='40%' border='1' cellpadding='0' cellspacing='0' class='table' align='center'> <tr> <td class='header' align='center' colspan='2'>Change Rank?</td> </tr> <tr> <td class='omg' align='center'>This will change the <strong>posted</strong> users Rank and Rep!</td> </tr> <tr> <td align='right'>Username:</td><td><input type='text' name='nameinput' class='input'></td> </tr> <tr> <td align='right'>Rank:</td><td><input type='text' name='rankinput' class='input'></td> </tr> <tr> <td align='right'>Rep:</td><td><input type='text' name='repinput' class='input'></td> </tr> <tr> <td align='center' colspan='2'><input type='submit' name='selectname' class='button'></td> </tr> </table> </form> </body> </html> Anyone able to see where I'm going wrong? Thanks Hi. im baffled on this. boss wants a traffic feed for the office so im using SimplePie to grab rss feeds and the google maps traffic overlay as a view of the roads. The trouble is when i do it via xampp locally it looks fine, but when i load into onto our local webserver (ubuntu 18.04 with apache) it only shows a small line and cant figure out why? any help is appreciated. The attached images are how my local xampp sees it and the other is via the ubuntu 18.04 with apache, php & mysql installed My Code is below <?php // Include the SimplePie library require_once('php/autoloader.php'); // Because we're using multiple feeds, let's just set the headers here. header('Content-type:text/html; charset=utf-8'); // These are the feeds we want to use $feeds = array( 'http://m.highwaysengland.co.uk/feeds/rss/AllEvents.xml', 'https://traffic.wales/feeds/incidents-events/rss.xml', 'https://traffic.wales/feeds/roadworks/rss.xml', 'https://trafficscotland.org/rss/feeds/currentincidents.aspx', 'https://trafficscotland.org/rss/feeds/roadworks.aspx' ); // This array will hold the items we'll be grabbing. $first_items = array(); // Let's go through the array, feed by feed, and store the items we want. foreach ($feeds as $url) { // Use the long syntax $feed = new SimplePie(); $feed->set_feed_url($url); $feed->init(); // How many items per feed should we try to grab? $items_per_feed = 5; // As long as we're not trying to grab more items than the feed has, go through them one by one and add them to the array. for ($x = 0; $x < $feed->get_item_quantity($items_per_feed); $x++) { $first_items[] = $feed->get_item($x); } // We're done with this feed, so let's release some memory. unset($feed); } // We need to sort the items by date with a user-defined sorting function. Since usort() won't accept "SimplePie::sort_items", we need to wrap it in a new function. function sort_items($a, $b) { return SimplePie::sort_items($a, $b); } // Now we can sort $first_items with our custom sorting function. usort($first_items, "sort_items"); // Begin the (X)HTML page. ?> <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <title>Traffic Layer</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> <style type="text/css"> body { height: 100%; font:12px/1.4em Verdana, sans-serif; color:#333; background-color:#fff; } a { color:#326EA1; text-decoration:underline; padding:0 1px; } a:hover { background-color:#333; color:#fff; text-decoration:none; } div.header { border-bottom:1px solid #999; } div.item { padding-left:5px; border-bottom:1px solid #999; } div#site { padding:5px 0; width:300px; } /* Always set the map height explicitly to define the size of the div * element that contains the map. */ #map { height: 100%; } /* Optional: Makes the sample page fill the window. */ html, body { height: 100%; margin: 0; padding: 0; } footnote, p{ color:red; font:9px/1.4em Verdana, sans-serif; font-weight:bold; } </style> </head> <body> <!-- NEW --> <div class="row"> <div class="col-md-2"> <!-- BOF Simple Pie News Feed Info --> <div id="site"> <?php foreach($first_items as $item): $feed = $item->get_feed(); ?> <div class="chunk"> <h6><b><?php echo html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8'); ?></a></b></h6> <?php echo $item->get_content(); ?> <?php if ($enclosure = $item->get_enclosure()): ?> <div> <?php echo $enclosure->native_embed(array( )); ?> </div> <?php endif; ?> <p class="footnote">Source: <?php echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a'); ?></p> </div> <?php endforeach; ?> </div> <!-- EOF Simple Pie News Feed Info --> </div> <div class="col-md-10"> <!-- BOF Map Info --> <div id="map"></div> <script> function initMap() { var map = new google.maps.Map(document.getElementById('map'), { zoom: 7.4, center: {lat: 53.8059821, lng: -1.6057714} }); var trafficLayer = new google.maps.TrafficLayer(); trafficLayer.setMap(map); } </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=<My Google API Key>&callback=initMap"> </script> <!-- EOF Map Info --></div> </div> <!--OEF Test --> </script> </body> </html>
The php web video script that I'm using displays user/member account pages in google searches. For example, the url displaying the page is the https://webvideosite.com/@chrisj I'm looking for guidance/suggestions on how to have the user/member account pages not appear in searches, either by blocking that somehow, or only having access to it if you are logged into the site. I look forward to any replies If you goto http://www.actionfx.net/bfd/photos.php you will see that im trying to show an rss feed from http://picasaweb.google.com/data/feed/base/user/114565750484201639035?alt=rss&kind=album&hl=en_US&access=public My code works well if its just text on the rss but it does not work on this particular rss. I want the photos to show up on my page also. Im hoping someone here can be so kind to help me out with this coding. Below is my code. Code: [Select] <?php $feed_url = "http://picasaweb.google.com/data/feed/base/user/114565750484201639035?alt=rss&kind=album&hl=en_US&access=public"; // INITIATE CURL. $curl = curl_init(); // CURL SETTINGS. curl_setopt($curl, CURLOPT_URL,"$feed_url"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); // GRAB THE XML FILE. $xmlTwitter = curl_exec($curl); curl_close($curl); // SET UP XML OBJECT. // Use either one of these, depending on revision of PHP. // Comment-out the line you are not using. //$xml = new SimpleXMLElement($xmlTwitter); $xml = simplexml_load_string($xmlTwitter); // How many items to display $count = 10; // How many characters from each item // 0 (zero) will show them all. $char = 100; foreach ($xml->channel->item as $item) { if($char == 0){ $newstring = $item->description; } else{ $newstring = substr($item->description, 0, $char); } if($count > 0){ //in case they have non-closed italics or bold, etc ... echo"</i></b></u></a>\n"; echo" <div style='font-family:verdana; font-size:.12;'> <b>{$item->title}</b><br /> $newstring ... <span class='redlink' id='redlink' style='redlink'> <a href='{$item->guid}'>read more</a> </span> <br /><br /> </div> "; } $count--; } ?> I've got another funny one... I've noticed that sometimes on some of my pages (all of which are generated by PHP), when i click view source, the source it shows me is not from the page i'm looking at. This isn't a problem that affects me in any way (not yet anyway), it's just a bit odd. I've noticed it happens a little more often in chrome than any other browser. Has anyone else noticed anything like this before? I'm intrigued to know the cause. The only real google response was this: http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg144609.html and i haven't seen another issue similar on here. i have built pages that paginate with 10 rows per page (some pages show more but for the moment i want to focus on this particular page)
//Define Some Options for Pagination $num_rec_per_page=10; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * $num_rec_per_page; $results = mysql_query("SELECT * FROM `ecmt_memberlist` WHERE toonCategory='Capital' AND oldMember = 0 ORDER BY CONCAT(MainToon, Name) LIMIT $start_from, $num_rec_per_page") or die(mysql_error()); $results_array = array(); while ($row = mysql_fetch_array($results)) { $results_array[$row['characterID']] = $row; }The above sets the variables for the pagination and below the results are echo with 10 rows per page then i show the pagination links: <?php $sql = "SELECT * FROM `ecmt_memberlist` WHERE toonCategory='Capital' AND oldMember = 0 ORDER BY CONCAT(MainToon, Name)"; $rs_result = mysql_query($sql); //run the query $total_records = mysql_num_rows($rs_result); //count number of records $total_pages = ceil($total_records / $num_rec_per_page); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"><div style="width:100%; text-align:center;"> <ul class="pagination"> <li class="selected"> <?php echo "<a href='capitalmember.php?page=1'>".'«'."</a> ";?> </li> <? for ($i=1; $i<=$total_pages; $i++) { echo "<li><a href='capitalmember.php?page=".$i."'>".$i."</a></li> "; }; ?> <li class="selected"> <? echo "<a href='capitalmember.php?page=$total_pages'>".'»'."</a> "; // Goto last page ?></li> </ul></div> <?php $pageNr = $page; // Get Current Page Number $from = $pageNr * $rowsPerPage; // 3 * 10 = 30 // 3 * 10 = 30 $to = $from + $rowsPerPage; // 30 + 10 = 40 echo $pageNr; /* Result: From page 30 to 40 */ ?></td> </tr> </table>this works great and shows me 10 results per page, what i need to work out and work on next is: echo the number of results above the records (for example: "showing records 1 to 10" and then on page 2 "showing records 11 to 21" and page 3 "showing records 22 to 32" how can i work out the maths for this echo? i was thinking along the lines of; <?php $pageNr = $page; // Gets Current Page Number $from = $pageNr * $rowsPerPage; // 3 * 10 = 30 $to = $from + $rowsPerPage; // 30 + 10 = 40 // Now Show Results echo $from; // Echo from echo $to // Echo to ?>but i'm still working on this.. then i need to look at shortening the amount of page links on the page if for example i have 500 records it shows me links 1 to 50 and eats up the page.... Appreciate any help and light onto my problems. Many thanks Edited by jacko_162, 11 January 2015 - 05:43 PM. I had a wordpress site setup for my maintenance company. I am not trying to setup a blog on the site. I have the blogroll showing up on this page: http://handymore.com/blog/ but when you click the individual articles the single post page shows a Error 404 message. Could anyone point me in the right direction as to how to fix this so that the individual post pages are found? Any guidance would be appreciated. |