Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hey there guys. I want first to thank you for helping me in my previous topic : http://forums.phpfreaks.com/topic/294511-not-saving-session-data-after-log-in/ But now i did not run throw a code problem yet throw a diff type of problems. After reading the "posting rules" or forgot what it name was i realize that this post is probably a bad idea. But here is the problem. I am working on a system that can read the files of a my server witch i have in my home. Yet after searching for days litterly i couldn't find any way or functions or even a hint to build a php function in order to read the files in the directory of the server. So all i ask for is not for you to write any bit of code or any thing just if you know even a small bit of what im looking for to post it as a reply so i can finish my project . Or if you know any tutorials on it. After all i don't just want it to work but to also understand what is going on. Thanks for reading.
  2. Good Day, So this is the scenario. i have two tables Organization, and Course, so in organization.tbl i have org_name, org_description, and course_id and in course.tbl i have course_id, course_name. there is no problem in inserting the org_name and org_description but i have a problem in inserting the multiple course_id into organization.tbl This is my checkbox script. <?php $query = "SELECT * FROM course"; $result = mysql_query($query); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> <input type="checkbox" name="course" value="<?php echo $line["course_name"]?>"> <?php echo $line["course_name"]?> <br> <?php } ?> now how to insert multiple course id into org.tbl this is my query in saving the course_id. <?php if (isset($_POST['save'])) { $course_id = $_POST['course_id']; mysql_query("insert into organization (course_id) values ('$course_id') ") or die(mysql_error()); } ?>
  3. I must use a hyperlink like this: <a href="https://www.pic-vert.fr/obm/availabilitycalendar.php?id=1&month=2&year=2015&ln=nl"> I want to make it dynamic so that month=2 changes into month='current month' and year = 2015 changes into year = current year. Any help available ? Thanks a lot, Freddy (beginner)
  4. Hi, wish somebody can help me T_T I'm little bit confused how to make user log-in based on country or territory, what I'm talking about is like this: The User table is: id_user | username | password | level | id_country The Country table is: id | country_name And when user login, there's a data entry form and there is a drop-down/combo-box in a form, that filled with user countries, like this: Country: [____] --> This part is automatically filled/disabled field if a user log-in with their username based on level and countries. Province: [____] --> This is a chained combo-box from countries City: [____] --> Also this chained to Province What I mean is, when user's log-in with their country id, so the "Country Combo-Box" will be automatically filled and disabled. So user can't choose another country, only their country based on username and territories. Thank you for all your help. Best regards, Kris I have this scripts: login_form.php <div><center> <form name="logForm" method="post" action="login_validation.php"> <table class="table-list" width="500" border="0" cellpadding="2" cellspacing="1" bgcolor="#999999"> <tr> <td width="106" rowspan="5" align="center" bgcolor="#CCCCCC"><img src="images/padlock.png" width="116" height="75" /></td> <th colspan="2" bgcolor="#CCCCCC"><b>LOGIN FORM </b></td> </tr> <tr> <td width="117" bgcolor="#FFFFFF"><b>Username</b></td> <td width="263" bgcolor="#FFFFFF"><b>: <input name="txtUser" type="text" size="30" maxlength="20" /> </b></td> </tr> <tr> <td bgcolor="#FFFFFF"><b>Password</b></td> <td bgcolor="#FFFFFF"><b>: <input name="txtPassword" type="password" size="30" maxlength="20" /> </b></td> </tr> <tr> <td bgcolor="#FFFFFF"><b>Access Level</b></td> <td bgcolor="#FFFFFF"><b>: <select name="comboLevel"> <option value="BLANK">- Choose -</option> <?php $level = array("operator", "admin"); foreach ($level as $p) { if ($_POST['comboLevel']==$p) { $check="selected"; } else { $check = ""; } echo "<option value='$p' $check>$p</option>"; } ?> </select> </b></td> </tr> <tr> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"><input type="submit" name="btnLogin" value=" Login " /></td> </tr> </table> </form> </center></div> and this validation script: login_validation.php <?php if(isset($_POST['btnLogin'])){ $msgError = array(); if ( trim($_POST['txtUser'])=="") { $pesanError[] = "Username </b> cannot empty !"; } if (trim($_POST['txtPassword'])=="") { $msgError[] = "Password </b> cannot empty !"; } if (trim($_POST['comboLevel'])=="BLANK") { $msgError[] = "Level</b> not picked !"; } $txtUser = $_POST['txtUser']; $txtUser = str_replace("'","´",$txtUser); $txtPassword=$_POST['txtPassword']; $txtPassword= str_replace("'","´",$txtPassword); $comboLevel =$_POST['comboLevel']; if (count($msgError)>=1 ){ echo "<div class='mssgBox'>"; echo "<img src='images/exclamation.png'> <br><hr>"; $noMsg=0; foreach ($msgError as $index=>$show_msg) { $noMsg++; echo " $noMsg. $show_msg<br>"; } echo "</div> <br>"; include "login.php"; } else { $loginSql = "SELECT * FROM user WHERE username='".$txtUser."' AND password='".md5($txtPassword)."' AND level='$comboLevel'"; $loginQry = mysql_query($loginSql, $conndb) or die ("Query Error : ".mysql_error()); if (mysql_num_rows($loginQry) >=1) { $loginData = mysql_fetch_array($loginQry); $_SESSION['SES_LOGIN'] = $loginData['id_user']; $_SESSION['SES_USER'] = $loginData['username']; if($comboLevel=="admin") { $_SESSION['SES_ADMIN'] = "admin"; } if($comboLevel=="operator") { $_SESSION['SES_OPERATOR'] = "operator"; } // Refresh echo "<meta http-equiv='refresh' content='0; url=?page=Main-Page'>"; } else { echo "You Not Login As ".$_POST['comboLevel']; } } } ?> Thank you for all help.... T_T thank you..
  5. I would like to know how can I redirect a jquery dialog function to a different page, if another function is true? For eg. 1. User 1 sends a request to User 2. 2. User 2 accepts the request. 3. User 1 still has the request "dialog" window open. Instead, I would like to have that dialog window close and redirect to a specified page. Of course this only happens after User 2 accepts the request and I check against it in the database. Here is the function for when User 1 makes a request. <script> $(function() { $("#new-dialog").dialog({ resizable: true, autoOpen: false, modal: true, width: 600, height: 300, buttons: { "Cancel Trade": function(e) { $(this).dialog("close"); $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=cancelTrade", success:function(data){ if(data == true) { alert('success'); } else { alert('not deleted'); } //window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; } }); } } }); $(".dialogify").on("click", function(e) { e.preventDefault(); $("#new-dialog").html(""); $("#new-dialog").dialog("option", "title", "Loading...").dialog("open"); $("#new-dialog").load(this.href, function() { $(this).dialog("option", "title", $(this).find("h1").text()); $(this).find("h1").remove(); }); }); }); </script> And here is the new function in which I check the database for match. If it returns true, I would like to redirect the above dialog/page. <script> $('document').ready(function(){ function checkTrade() { $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=checkTrade", success:function(data){ window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; } }); } }); </script> So what am I missing to do the redirect?
  6. hi everyone, thanks in advance. i have one issue regarding cookie based authentication with curl. i have an application which calls a third party php url for user registration and authentication. when we called athentication with third party url using curl the result shows succes and cookie is building. again i need to call another url from same third party server which displays a flash. once the authentication is success the flash automatically logins. but for me flash ask for username and password, it should n't be like that. i hope my curl call not building cookie in right format. please check my code and give suggestions. <?php $result=$name=$pass=""; $name= $_SESSION["name"]; $pass=$_SESSION["pass"]; $ch = curl_init(); $cookie_file_path = 'my_cookie.txt'; $cookie_file_path = realpath($cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); curl_setopt($ch, CURLOPT_VERBOSE, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //new ones curl_setopt($ch, CURLOPT_HEADER, 1); // here i am calling third party url for athentication curl_setopt($ch, CURLOPT_URL,"http://thirdpartyserver.com/checksession.php?username=".$name."&passme=".$pass); $result= curl_exec ($ch); if ($result==true) { //here i am calling the third party flash which is embed in this page. flash should automatically login with cookie. header( "refresh:1;url= http://myserver/testfolder/flashLoader.php" ); } ?> please let me my code is correct, and thanks for your suggestions. thanks vinz
  7. Hi all, I need some guidance and hoping some of you might be able to point me in the right direction. I am working on a project for a client that includes a very large database of business contacts and a simple one line search box. I will explain as best I can: The database contains prefix, first name, last name, company name, company type (roofing, tiling, flooring...etc), address, city, county, zip code, phone number and other variables. The search box on the websites homepage is only one line. The pre-populated text says: Enter Business type, city, county or zipcode. The user is "supposed" to add a type of business (I.e. Roofing, tiling, dry walling ...etc) followed by either a city, a county or a zip code. I need to figure out how to take this text (I.e. Roofing macomb county, or, Roofing 48333, or Roofing Detroit) and first find all companies that match type (roofing) and then match either city, county or zipcode, depending on what the user enters. Traditionally, I have used multi-part search boxes, such as a drop down for company type, text box for city, county or zip, and assigned each as a search variable, easy stuff, but I am unsure as to how I would progress with a single text string that I'm not even sure how a customer will enter. They could, for example, type the zipcode or city first, followed by the company type (I.e. 48333 roofing) or they may not enter a company type at all, simply entering a zip code, in which case I'd have to be able to prompt them to add a company type as well so we know which companies to return. Could anyone please give me some advice on how I should start on this? I have 2 weeks to complete the entire project and this is the only area I am unfamiliar with. The rest is just a lot of coding and pretty standard. Thank you so much in advance!
  8. I am trying to setup so that I select a name from the dropdown menu (already works) then taking the ID number and using it to update multiple tables. I cannot get it to update anything. I don't really know what I am doing here, I thought based on other coding I have used that this would be simple. Please Help?? <? require('../edb.php'); $aid =$_REQUEST['aid']; if (isset($_POST['Submit'])) { $mysql_query1("UPDATE `adocs_ar_cert` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query2("UPDATE `adocs_cpd` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query3("UPDATE `adocs_fds` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query4("UPDATE `adocs_fsg_profile` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query5("UPDATE `adocs_sapl` SET Current='N' WHERE AdviserCode='$aid'"); }?>
  9. I am fairly new at programming and I am running into a problem. What I am trying to do is have my login.php create and declare the session variables, then my dashboard.html file should only show the current html if $_SESSION['isloggedin'] is set. I tested to make sure login.php was declaring the session variable and it is. Im not sure what I am doing wrong, any help is greatly appreciated. I left out a lot of the dashboard html in the middle because it is quite extensive. Thanks! Login.php ?php session_start(); include 'dbconnect.php'; $username = $_POST['username']; $password = $_POST['password']; function login($email, $password) { $login = mysql_query("SELECT * FROM (Teachers) where email = '$email' and password = '$password'"); if (mysql_fetch_row($login)>0){ if(!$login){ die('Could not securely login to your account. Error e09993'); } else{ $_SESSION['name']= mysql_fetch_row($login)[2]; $_SESSION['email']= mysql_fetch_row($login)[1]; $_SESSION['lastName']= mysql_fetch_row($login)[3]; $_SESSION['birthdate']=mysql_fetch_row($login)[4]; $_SESSION['teacherCode']=mysql_fetch_row($login)[6]; $_SESSION['active']= mysql_fetch_row($login)[8]; $_SESSION['isloggedin']= true; } } else{ echo "Invalid Username/ Password"; exit(); } } login($username, $password); //header('Location: ..\dashboard.html'); ?> Top Dashboard.html <?php include 'dbconnect.php'; session_start(); if(isset($_SESSION['isloggedin'])) { ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content="Dashboard"> <meta name="keyword" content="Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina"> <title>DASHGUM - FREE Bootstrap Admin Template</title> <!-- Bootstrap core CSS --> <link href="assets/css/bootstrap.css" rel="stylesheet"> <!--external css--> <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" /> <link rel="stylesheet" type="text/css" href="assets/css/zabuto_calendar.css"> <link rel="stylesheet" type="text/css" href="assets/js/gritter/css/jquery.gritter.css" /> <link rel="stylesheet" type="text/css" href="assets/lineicons/style.css"> <!-- Custom styles for this template --> <link href="assets/css/style.css" rel="stylesheet"> <link href="assets/css/style-responsive.css" rel="stylesheet"> <script src="assets/js/chart-master/Chart.js"></script> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <section id="container" > <!-- ********************************************************************************************************************************************************** TOP BAR CONTENT & NOTIFICATIONS *********************************************************************************************************************************************************** --> <!--header start--> <header class="header black-bg"> <div class="sidebar-toggle-box"> <div class="fa fa-bars tooltips" data-placement="right" data-original-title="Toggle Navigation"></div> </div> Bottom Dashboard.html </html> <?php } ?> dashboard.html login.php
  10. So XSS attacks, are you safe from them if you are outputting the data into lets say a input box, without any security checks like htmlentites()? And does PDO prepare help prevent xss too? And what sort of functions should I use to be most secure of outputting data in input boxes, text etc.
  11. hi , I wrote this code with C # And 50 of Google's search results will show c# code GwebSearchClient client = new GwebSearchClient("WWW.blogfa.com"); IList<IWebResult> results = client.Search(" Test ", 50); // foreach (IWebResult result in results) { listBox1.Items.Add(result.VisibleUrl); } The PHP code is the same as C # code ,But why only 4 examples displays? What changes should I do in the PHP code? php code <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php /** * google_search_api() * Query Google AJAX Search API * * @param array $args URL arguments. For most endpoints only "q" (query) is required. * @param string $referer Referer to use in the HTTP header (must be valid). * @param string $endpoint API endpoint. Defaults to 'web' (web search). * @return object or NULL on failure */ function google_search_api($args, $referer = 'http://localhost/test/', $endpoint = 'web'){ $url = "http://ajax.googleapis.com/ajax/services/search/".$endpoint; if ( !array_key_exists('v', $args) ) $args['v'] = '1.0'; $url .= '?'.http_build_query($args, '', '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // note that the referer *must* be set curl_setopt($ch, CURLOPT_REFERER, $referer); $body = curl_exec($ch); curl_close($ch); //decode and return the response return json_decode($body); } $rez = google_search_api(array( 'q' => 'Test', )); //results[$x]->url; print_r($rez); ?>
  12. een experiencing internal error message on my website for some time now. After being sent the error log, i got this; 20150210T084758: www.traditnow.com/index.php PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /hermes/bosoraweb136/b1865/ipg.traditnowcom/wp-content/themes/classipress/includes/functions.php on line 1079 I eventually found the line of code but could not figure out where the error is. echo $currentBefore . __( 'Ads tagged with', APP_TD ) . ' '' . single_tag_title('', false) . ''' . $currentAfter; please help me anybody. i wouldn't mind if someone will help rewrite it. Any one please... echo $currentBefore . __( 'Ads tagged with', APP_TD ) . ' '' . single_tag_title('', false) . ''' . $currentAfter; Thank you
  13. Could anybody please give me a regex for numbers and dashes only? Thanks
  14. After all the fields have been confirmed on my Registration Form, just before the confirmation email is sent out to the user, I have this code to create a MySQL db from their unique username: require_once 'login.php'; echo $uname; try{ $stmt = $db->prepare("CREATE DATABASE IF NOT EXISTS :dbname"); $stmt->bindValue(':dbname', $uname, PDO::PARAM_STR); $stmt->execute(); } catch (PDOException $ex){ echo 'Error creating database: '.$ex; } My apache error log is clear. Same for MySQL eorror log. No errors reported. I have even commented out the bindValue $stmt and put a name in place of :dbname in the prepare $stmt, but I still get nothing. Anyone see what I'm doing wrong?
  15. if i have one url say www.example1.com.I want to display the same contents on another url say www.example2.com.How can i do it using php code?
  16. Hey there. My name is Jamie, and I have been creating websites for about 7 years now. I have freelanced several times in the past, and had a full time job coding with PHP over the summer. My specialty is PHP/MySQLi, but in terms of web development I also know javascript (jquery), HTML and CSS. My prices are pretty good, I'm willing to bargain if necessary. I'm more interested in big jobs, but I'm totally fine with doing small ones if it comes up. If you are interested in my services, you can contact me at jccreaghan@gmail.com or by skype at repentance193 Thanks and have a good day!
  17. Hello all, I need some help with my database. So far I have made a program that collects information from a mysql database and I can edit the information and all. Anyways, I use that program to keep track of my job orders but as it stands now I have to enter it all myself. Is there a way that I can have paypal or a php enter the clients name, email, order ID (dont even know how to do this in paypal), and what product he bought in a table on my database? Ill provide screenshots of my program and also database table. Dont know if it will help but it might a bit. By the way, I dont have a clue about php.
  18. Let me put this straight. I have a table : name_table name varchar(10), meaning1 varchar(10), meaning2 varchar(10) ... meaning20 varchar(10). #Note : The Fields Name & Meaning2 are already Filled. Test.php (URL Passed : localhost/../test.php?name=some_name) <?php error_reporting(E_ALL); $servername = "localhost"; $username = "root"; $password = ""; $dbname = "test_db"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //Get name $name = $_GET['name']; $name_meanings = array(sometext1, sometext2, ... sometext19, sometext20); for($k=1; $k<=20; $k++){ //check if the table cell is empty to be filled $element_col = "meaning" . $k; echo "</br>" . $element_col . "</br>"; $check = $conn->query("select $element_col from name_table WHERE name=$name"); if(!$check){ echo "</br> CHECK: False</br>"; $occurance = mysqli_num_rows($check); //Warning message pointing to this line if($occurance == 0 ){ echo "</br>Occurance is 0</br>"; for($l=0; $l<sizeof($name_meanings); $l++){ $name_element = $name_meanings[$l]; $raw_pwd=$conn->query("insert into name_table($element_col) values($name_element) where name=$name"); } } else{ echo "</br>Meaning exists at $element_col</br>"; } } else{ echo "</br>Check is True</br>"; break; } } ?> Output: Meaning1 Check: False Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\\test.php on line 26 Occurrence is 0 Meaning2 <--This iteration went wrong Check: False Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\\test.php on line 26 Occurrence is 0 . . . Meaning20 Check: False Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\\test.php on line 26 Occurrence is 0 Question: 1. How do I put the warning, mysqli_num_rows() right? 2. Why is the PHP unable to detect the already inserted fields (meaning2)? Any Suggestion.....Please.
  19. Hey there im trying to make a log in and register system where when the user log in in the header it shows him a message greeting him with his username and when he is not logged it shows him a message greeting him as a guest. My problem is i suppose that in the header page (member.php page) the sessions are not saved and the user is never logged in. While testing my code . The user after logging in successfully it redirect him to member.php page where it should show him the username and all that. Yet it doesn't. Here are my codes : TO BE NOTICED I DID REMOVE RGE ERROR_REPORTING(0); AND THE OTHER ONE BUT NOTHING HAPPENED. SO NO ERRORS. member.php : <?php error_reporting(E_ALL ^ E_NOTICE); error_reporting(0); session_start(); $userid = $dbid; $username = $dbuser; $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <LINK REL=StyleSheet HREF="css/styletest.css" TYPE="text/css"> </head> <body> <div id="wrapper"> <!-- Website menu --> <div id="menu-bar"> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> </div> <!-- End of Website menu --> <div id="content"> <!-- Website header --> <div id="header"> <h1>Testing header</h1> <?php if ($username && $userid) { echo $username; } else { echo 'Welcome guest'; } ?> </div> <!-- End of Website header --> <!-- -----Website content----- --> <h2>Log in</h2> <?php $form='<form action="login.php" method="POST"> <table> <tr> <td>Username :</td> <td><input type="text" name="user"></td> </tr> <tr> <td>Password :</td> <td><input type="password" name="pass"></td> </tr> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <td><input type="submit" name="loginbtn" value="Log in"></td> </tr> </table> </form>'; $user = $_POST['user']; $pass = $_POST['pass']; if ($_POST['loginbtn']) { if ($user) { if ($pass) { require 'core/connect.php'; $query = mysql_query("SELECT * FROM users WHERE username = '$user' "); $row = mysql_fetch_assoc($query); $passwordFromPost = $_POST['pass']; $hashedPasswordFromDB = $row['password']; if (password_verify($passwordFromPost, $hashedPasswordFromDB)) { $query = mysql_query("SELECT * FROM users WHERE username = '$user' "); $numrows = mysql_num_rows($query); if ($numrows == 1) { $query = mysql_query("SELECT * FROM users WHERE username = '$user' "); $row = mysql_fetch_assoc($query); $dbactive = $row['active']; $dbuser = $row['username']; if ($dbactive == 1) { $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; echo "You have been logged in as <b>$dbuser</b> <a href='./member.php'>Click here</a> to go back to home page"; } else { echo '<font color="red">You must activate your account to log in.</font>'; echo $form; } } else { echo '<font color="red">You entered an invalid username or password.</font>'; echo $form; } } else { echo '<font color="red">You entered an invalid username or password.</font>'; echo $form; } mysql_close(); } else { echo '<font color="red">You must enter your password.</font>'; echo $form; } } else { echo '<font color="red">You must enter your username.</font>'; echo $form; } }else{ echo $form; } ?> <p>Testing website content</p> <!-- End of Website content --> </div> <!-- Website footer --> <div id="footer"> </div> <!-- End of Website footer --> </div> </body> </html> And here is login.php : <?php error_reporting(E_ALL ^ E_NOTICE); error_reporting(0); session_start(); $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <LINK REL=StyleSheet HREF="css/styletest.css" TYPE="text/css"> </head> <body> <div id="wrapper"> <!-- Website menu --> <div id="menu-bar"> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> <li><a href="">Testing links</a></li> </div> <!-- End of Website menu --> <div id="content"> <!-- Website header --> <div id="header"> <h1>Testing header</h1> <?php if ($username && $userid) { echo $username; } else { echo 'Welcome guest'; } ?> </div> <!-- End of Website header --> <!-- -----Website content----- --> <h2>Log in</h2> <?php $form='<form action="login.php" method="POST"> <table> <tr> <td>Username :</td> <td><input type="text" name="user"></td> </tr> <tr> <td>Password :</td> <td><input type="password" name="pass"></td> </tr> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <td><input type="submit" name="loginbtn" value="Log in"></td> </tr> </table> </form>'; $user = $_POST['user']; $pass = $_POST['pass']; if ($_POST['loginbtn']) { if ($user) { if ($pass) { require 'core/connect.php'; $query = mysql_query("SELECT * FROM users WHERE username = '$user' "); $row = mysql_fetch_assoc($query); $passwordFromPost = $_POST['pass']; $hashedPasswordFromDB = $row['password']; if (password_verify($passwordFromPost, $hashedPasswordFromDB)) { $query = mysql_query("SELECT * FROM users WHERE username = '$user' "); $numrows = mysql_num_rows($query); if ($numrows == 1) { $query = mysql_query("SELECT * FROM users WHERE username = '$user' "); $row = mysql_fetch_assoc($query); $dbactive = $row['active']; $dbuser = $row['username']; if ($dbactive == 1) { $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; echo "You have been logged in as <b>$dbuser</b> <a href='./member.php'>Click here</a> to go back to home page"; } else { echo '<font color="red">You must activate your account to log in.</font>'; echo $form; } } else { echo '<font color="red">You entered an invalid username or password.</font>'; echo $form; } } else { echo '<font color="red">You entered an invalid username or password.</font>'; echo $form; } mysql_close(); } else { echo '<font color="red">You must enter your password.</font>'; echo $form; } } else { echo '<font color="red">You must enter your username.</font>'; echo $form; } }else{ echo $form; } ?> <!-- End of Website header --> <!-- -----Website content----- --> <p>Testing website content</p> <!-- End of Website content --> </div> <!-- Website footer --> <div id="footer"> </div> <!-- End of Website footer --> </div> </body> </html> Now i don't think that in login.php there is any problem because i tested the page and every thing works fine even this code : echo "You have been logged in as <b>$dbuser</b> <a href='./member.php'>Click here</a> to go back to home page"; Where it shows him his username yet in member.php nothing happens. Thanks for reading.
  20. Hello, i am new to php and from this project i have started my php learning so first of sorry if my question is simple to ask but its difficult for me to understand the error and i want to learn php so i really need from all php expert available here. so i am getting error in generating news or latest post.. here is my code <? include("includes/connect.php"); $select_posts = "select * from posts order by rand() LIMIT 0,2"; $run_posts = mysql_query($select_post); while($row=mysql_fetch_array($run_post)){ $title = $row ['post_title']; $date = $row ['post_date']; $author = $row ['post_author']; $image = $row ['post_image']; $content = substr($row ['post_content'],0,200);+ } ?> <h2><?php echo $title; ?></h2> Following i am getting in my news page : Notice: Undefined variable: title in G:\wamp\www\rect\includes\news_data.php on line 16
  21. This isn't really a "programming question", I'd just like some advice really. I have been asked to write a paper by my boss on how we can go about recruiting for our developer roles people who (most likely) are not developers and will not have had any development experience of any kind. The reason for this, is that we have an external recruitment ban within our organisation (which sucks, but there is nothing I can do about it). We have about 20 developer jobs within our team. I work for a government organisation that has thousands of jobs for various purposes such as Finance, Statistics, Contracts - I'm not really sure what else, it's such a massive organisation - but nearly all the IT is outsourced to contractors apart from our little team. Any recruitment we do, they must already be a civil servant. So if they happen to love a bit of web development in their spare time then fantastic, but realistically, they probably won't. So how do you identify if they "have what it takes" to become a developer? Are there any official aptitude tests they can take that will show they are of the right mindset - ha - is there even a right mindset?! Other areas of our organisation use MS Excel a lot. Maybe there is some way of testing their VBA ability which would determine if they'd make a kick-ass programer or not?? I am open to all ideas here!!!
  22. hey guys, HOpe you can help me. I need a code about "Lock out after serveral attemps", and "Change password after first login"
  23. I have a form set up. One part of that form is a couple radio buttons. The form code for them is: <label for="who" class="label">Email to:</label> <input type="radio" name="who" value="Sales" checked>Sales <input type="radio" name="who" value="Support">Support In my PHP code, I have this to check which one they selected: if($who=="Sales") { $to = "sales@mysite.co"; $subject = "Contact Email"; $headers = "From:" . $email; mail($to,$subject,$msg,$headers); header("Location: mailreceived.html"); } else { $to = "support@mysite.co"; $subject = "Contact Email"; $headers = "From:" . $email; mail($to,$subject,$msg,$headers); header("Location: mailreceived.html"); } But even when I select the Sales radio button, the email is sent to Support. What am I not doing right in my If statement?
  24. GOAL: echo switch statement case which maps/matches to 'postType' PROBLEM: Regardless of what I try, the $_POST data seems to vanish, thus the switch statements default case is triggered and the form shows again instead of the intended/desired echo statement that I hope to show based on the postType contained within the $filter variable. I am working in PHP 5.4 A var_dump returns: array(2) { ["postType"]=> NULL ["myContent"]=> string(4) "dsfs" } I believe that I have both the form and the switch statement syntaxs/formatting correct. My problem, i think is somewhere in how the data is or isn't being passed to the switch via the filter_input_array(INPUT_POST, [...]) my humble code stub: error_reporting(E_ALL | E_STRICT); define('THIS_PAGE',basename($_SERVER['PHP_SELF'])); //test data //$_POST = [ 'postType' => 'myPlayby', 'myContent' => 'Anna King', ]; //build the array of data created by from for switch checks $filter = filter_input_array(INPUT_POST, [ 'postType' => [], 'myContent' => [], ]); var_dump($filter); echo "<br /><br />"; //$search = false; switch ($filter['postType']) { case 'myChar': echo "Character Check: " . $filter['myCharacter']; $search = $filter['myCharacter']; break; //test data ought to trigger myPlayby case showing 'Playby check: Anna King' here... frack case 'myPlayby': echo "Playbe Check: " . $filter['myPlayby']; $search = $filter['myPlayby']; break; case 'myFoobar': echo "Foo Check: " . $filter['myFooBar']; $search = $filter['myFooBar']; break; default: echo '<form type="submit" method="post" action="' . THIS_PAGE . '"; > <select name="postTypes"> <option default disable>-------------</option> <option value="myChar">Character</option> <option value="myPlayby">Playby</option> <option value="myFooBar">Foo</option> </select> <input type="text" value="" name="myContent"/> <input type="submit" name="submit" value="Submit"> </form>' ; break; } This is my first time working with filter_input_array to handle $_POST data, and after a day of trial, error, research and effort which include looking at Lynda.com, searching Google and reading what relevant posts I could find on StackOverflow, php.net, etc, I am flummoxed.test-switch-stack.php
  25. Hi I am trying to build a contact form and my form isnt sending. Here is my code. (its in a modal window)(I have my email address in the $to variable in the code) <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Jarrod'; $to = 'email'; $subject = "Landing page"; $body = "From: $name\n Email: $email\n Message:\n $message"; ?> <?php if ($_POST['submit']){ if(mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; }else{ echo '<p>Something went wrong, go back!</p>'; } } ?> <div class="modal fade" id="contact" role="dialog"> <div class=" modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h2>Contact us</h2> </div> <div class="modal-body"> <form method="post" action="index1.php"> <div class="form-horizontal"> <label for="Name">Your Name</label> <input type="text" class="form-control" id="name" placeholder="Name"> <label for="Email">Your Email</label> <input type="Email" class="form-control" id="email" placeholder="Email"> <label for="Message">Message</label> <textarea class="form-control" id="message" placeholder="Message"></textarea> <input type="submit" value="Send">Send</button> </form> <div class="modal-footer"> <a class="btn btn-default" data-dismiss = "modal">Close</a> </div> </div> </div> </div>
×
×
  • 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.