Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by gristoi

  1. yeah, just store the location in the db then once you have confirmed that they have a valid login assign the location to a variable and use it to redirect. for example you had a variable in your table called homepage:

    // query run here
    
    if($result) {
    	if(mysql_num_rows($result) == 1) {
    		//Login Successful
    		session_regenerate_id();
    		$member = mysql_fetch_assoc($result);
    		$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
    		$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
    		$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
    		session_write_close();
                            $page = $member['homepage'] ;
    		header("location: $page");//change as appropriate
    		exit();
    	}else {
    		//Login failed
    		header("location: login-failed.php");
    		exit();
    	}
    }
    

  2. you mean something like this?

    <?php
    //Start session
    session_start();
    
    //Include database connection details
    require_once('config.php');
    
    //Array to store validation errors
    $errmsg_arr = array();
    
    //Validation error flag
    $errflag = false;
    
    //Connect to mysql server
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if(!$link) {
    	die('Failed to connect to server: ' . mysql_error());
    }
    
    //Select database
    $db = mysql_select_db(DB_DATABASE);
    if(!$db) {
    	die("Unable to select database");
    }
    
    //Function to sanitize values received from the form. Prevents SQL injection
    function clean($str) {
    	$str = @trim($str);
    	if(get_magic_quotes_gpc()) {
    		$str = stripslashes($str);
    	}
    	return mysql_real_escape_string($str);
    }
    
    //Sanitize the POST values
    $login = clean($_POST['login']);
    $password = clean($_POST['password']);
    
    //Input Validations
    if($login == '') {
    	$errmsg_arr[] = 'Login ID missing';
    	$errflag = true;
    }
    if($password == '') {
    	$errmsg_arr[] = 'Password missing';
    	$errflag = true;
    }
    
    //If there are input validations, redirect back to the login form
    if($errflag) {
    	$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    	session_write_close();
    	header("location: login-form.php");
    	exit();
    }
    
    //Create query
    $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";
    $result=mysql_query($qry);
    
    //Check whether the query was successful or not
    if($result) {
    	if(mysql_num_rows($result) == 1) {
    		//Login Successful
    		session_regenerate_id();
    		$member = mysql_fetch_assoc($result);
    		$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
    		$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
    		$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
    		session_write_close();
                            switch($login)
                           {
                             case 'user': $direction = 'member-index.php';
                             break;
                             case 'Admin': $direction = 'admin-index.php';
                             break;
    
                            }
    		header("location: $direction");//change as appropriate
    		exit();
    	}else {
    		//Login failed
    		header("location: login-failed.php");
    		exit();
    	}
    }else {
    	die("Query failed");
    }
    ?>

  3. the image tag is using a $_GET paramater to return the image. because web pages are stateless( the next page does not know the state of the last page) you have to pass variables from page to page to keep a constant state.

    using $_GET in php is one method of doing this. It is basically concatenating the variables into the url so that it can be re interpreted by the target url. So basically your script is passing data to  linegraph.php. the ? tells it that you are passing $_GET paramaeters and the & is used to seperate each variable. i.e:

     

    <?php  www.mysite.com/page.php?var1=something&var2=somethingelse ?>

    and when the other page usese the get function they can re assign the variables:

     

    <?php
    $var1 = $_GET['var1'];
    $var2 = $_GET['var2'];
    ?>

  4. Hi, just a quick pointer, Where at all possible try to never use select *. This is purely from a performance perspective. if the email variable was the only thing you wanted returning from the db then use

    select email

    If the table you are selecting from had 20 columns ( for example ) there is no point returning the other 19 columns of data is there

  5. ok. that is a lot of code to go through. Easiest thing to do is to turn on your error handling and see what error it throws. Place this just below the opening php tag in your form.php:

    
    ini_set('display_errors',1);
    error_reporting(E_ALL|E_STRICT);

     

    this will display any errors thrown by the system. resubmit your form and see if any errors are shown

  6. Sorry, my bad, skipped right past it ( i blame my tiny iphone screen). try changing the button to an input type:

    from:

    <button class="art-button">Send </button></form>

    to

     

    <input type="submit" name="send" value = "send" class="art-button" /></form>

  7. at the very top of your php scripts.

    <?php
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
    
    // rest of script.
    

     

    note that you said this was a cms which could indicate ( and dont quote me lol) that it may be using the (MVC Pattern). which means that everything is routed through one page (usually the index.php). If this is the case then u only need to add it into the index page

  8. your current code looks like this:

     

       //E-mail address to send input to, change this
             $to="studio@rmdesignstudio.com.au";
             //Title of E-mail
             $subject="Website Quote Request Form - www.wraptinprint.com.au";
             //From
              $sendmail_from="$email";

     

    needs to be this:

       //E-mail address to send input to, change this
             $to="studio@rmdesignstudio.com.au";
             //Title of E-mail
             $subject="Website Quote Request Form - www.wraptinprint.com.au";
             //From
             $sendmail_from =  'From: '. { $email } ."\r\n";

     

  9. The best way to do this is really going to be the manual approach. Put your CMS on a server with PHP5 and turn on full error checking:

    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);

     

    The work through the warnings and errors, you will get a lot more warnings than fatal errors. work through and remove the depreciated functions and replace them with their php5 counterpart for each warning given. Shouldnt take more than a few hours

×
×
  • 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.