Jump to content

jonsjava

Members
  • Posts

    1,579
  • Joined

  • Last visited

Posts posted by jonsjava

  1. Creating a user:

    $username = addslashes($_POST['username'];
    $key = "thisisakey";
    $password = addslashes($_POST['password'];
    $enc_pass = md5($password.$key);
    $sql = "INSERT INTO `<table>`(`id`, `username`, `password`) VALUES('','{$username}', '{$enc_pass}');";
    mysql_query($sql);
    

     

    logging in a user:

    $username = addslashes($_POST['username'];
    $key = "thisisakey";
    $password = addslashes($_POST['password'];
    $enc_pass = md5($password.$key);
    $sql = "SELECT * FROM users WHERE user_name='{$username}' AND password='{$enc_pass}' AND activated='1';";
    

    change the code to suit your needs, but if you do it this way, you further encrypt your password with a "key", adding

    it to the end of their password.

  2. change

    $selected = mysql_select_db("*****",$dbhandle)
    or die("Can not open SLC Database");
    echo "Connected to Salt Lake City Database<p>";
    

    to:

    mysql_select_db("*****",$dbhandle)
    or die("Can not open SLC Database");
    echo "Connected to Salt Lake City Database<p>";
    

     

  3. <?php
    while($row = mysql_fetch_array($result))
    
      {
      $lastname=$row['lastname'];
      $firstname=$row['firstname'];
      
      echo $firstname ." ". $lastname;
      
      }
    $dirname = "ALBUMS/".$lastname;
    function returnimages($dirname) {
    $galleryarray = array();
    $pattern="\.(jpg|jpeg|png|gif|bmp)$";
    $files = array();
    $curimage=0;
    if($handle = opendir($dirname)) {
    	while(false !== ($file = readdir($handle))){
    		if(eregi($pattern, $file)){
    			$galleryarray[$curimage]=$file;
    			$curimage++;
    		}
    	}
    	closedir($handle);
    }
    return($files);
    }
    
    returnimages();
    ?>
    

    re-worked, but without having the full code, I can't promise it will work.

  4. mkdir may not be the best answer. try this:

    <?php
    $folder = $username; //Whatever values you like for what $folder equals
    $file = $filename; //what you want the file to be
    $fh = fopen($folder."/".$file, 'w+');
    $content = "this is the content going in the file";
    fwrite($fh, $content);
    fclose($fh);
    ?>
    

    This will make the file for you, in their folder, and place the content $content in it, and close the file back up.

  5. First, go to your mysql table (I hope you have a primary key set up), and do this:

    ALTER TABLE `auth` ADD UNIQUE (
    `userid`
    )
    

    This will stop people from creating 2 users with the same name. The database won't allow it. 2nd, you need to attempt a cleanup on your code:

    <?php
    $link = mysql_connect("localhost","luke2727_luke","********") or die("Unable to connect to SQL server");
    mysql_select_db("luke2727_login" ,$link) or die("Unable to select database");
    
    
    //  CHECK TO SEE IF USERNAME IS ALREADY IN USE - INFORM USER IF IT IS
    $newUser = addslashes($_POST['username']); //whatever your form uses for the username, change it in $_POST['HERE']
    $newPass = addslashes($_POST['password']);
    $sql = "SELECT * FROM auth WHERE username = $newUser;";
    $result = mysql_query($sql);
    while ($userinfo = mysql_fetch_array($result)){
    
    if ($newUser == $userinfo['username']) {
       $status = "* That name is taken";
    
    //  THE PART ABOVE WORKS FINE   
    
    } else if ($newUser != $userinfo['username']) {
    insert_database();
    }
    }
    
    // EVERYTHING FOLLOWING ELSE IF DOESN'T
    
    function insert_database($newUser, $newPass)
    {
    //  WHEN NEWUSER AND NEWPASS ARE ASSIGNED INSERT INTO DATABASE
    if ($newUser && $newPass) {
    $query = "insert into auth (userid,username,userpassword) ";
    $query .= "VALUES(0000,'$newUser','$newPass')";
    mysql_query($query) or die("Insert Failed!");
       }
       
       return;
    }
    ?>
    

     

     

  6. full code (working):

    <?php
    $galleryarray = array();
    $galleryarray[0]="P1120081.jpg"; 
    $galleryarray[1]="P1120082.jpg"; 
    $galleryarray[2]="P1120083.jpg"; 
    $galleryarray[3]="P1120084.jpg"; 
    $galleryarray[4]="P1120085.jpg"; 
    $galleryarray[5]="P1120086.jpg";
    
    foreach ($galleryarray as $ga) {
    echo "<img src='".$ga.">\n";
    }
    ?> 
    

  7. Right off the top, I see this:

    $prod_sel=mysql_fetch_assoc(mysql_query("SELECT * FROM vacante WHERE id='$id'"));
    $id=$prod_sel['id'];
    

    The problem with this is that you are defining $prod_sel by getting the information from $id, which is defined only after $prod_sel is defined. Neither variable can be filled, because they depend on the other. You *MUST* define one variable before you can define the other. Pick one, and define it.

  8. a modified version of a script I found at  http://elouai.com/force-download.php:

    <?php
    
    $filename = $_GET['file'];
    
    // required for IE, otherwise Content-disposition is ignored
    if(ini_get('zlib.output_compression'))
      ini_set('zlib.output_compression', 'Off');
    
    // addition by Jorg Weske
    $file_extension = strtolower(substr(strrchr($filename,"."),1));
    
    if( $filename == "" ) 
    {
      echo "<html><title>eLouai's Download Script</title><body>ERROR: download file NOT SPECIFIED. USE force-download.php?file=filepath</body></html>";
      exit;
    } elseif ( ! file_exists( $filename ) ) 
    {
      echo "<html><title>eLouai's Download Script</title><body>ERROR: File not found. USE force-download.php?file=filepath</body></html>";
      exit;
    };
    switch( $file_extension )
    {
      case "pdf": $ctype="application/pdf"; break;
      case "exe": $ctype="application/octet-stream"; break;
      case "zip": $ctype="application/zip"; break;
      case "doc": $ctype="application/msword"; break;
      case "xls": $ctype="application/vnd.ms-excel"; break;
      case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
      case "gif": $ctype="image/gif"; break;
      case "png": $ctype="image/png"; break;
      case "jpeg":
      case "jpg": $ctype="image/jpg"; break;
      case "mp4": $ctype="video/mp4"; break;
      default: $ctype="application/force-download";
    }
    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false); // required for certain browsers 
    header("Content-Type: $ctype");
    // change, added quotes to allow spaces in filenames, by Rajkumar Singh
    header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize($filename));
    readfile("$filename");
    exit();
    ?>

  9. change

    <?php
    if (!isset($_SESSION['SESS_MEMBER_ID'])){
    echo"
    <a name='login_top'></a>
    <form style='padding-left:10px;' id='loginForm' name='loginForm' method='post' action='#login_top'>
    $log_error
    <b>Login</b><br>
    <input name='login' type='text' id='login' /><br>
    <b>Password</b><br>
    <input name='password' type='password' id='password' /><br>
    <input style='margin-top:5px; height:23px; width:75px; font-size:10px;' type='submit' name='Login' value='Login' />
    </form>
    ";
    }
    
    elseif (isset($_SESSION['SESS_MEMBER_ID'])){
    include 'Login/member-index.php';
    }
    ?>
    

    to

    <?php
    session_start();
    if (!isset($_SESSION['SESS_MEMBER_ID'])){
    echo"
    <a name='login_top'></a>
    <form style='padding-left:10px;' id='loginForm' name='loginForm' method='post' action='#login_top'>
    $log_error
    <b>Login</b><br>
    <input name='login' type='text' id='login' /><br>
    <b>Password</b><br>
    <input name='password' type='password' id='password' /><br>
    <input style='margin-top:5px; height:23px; width:75px; font-size:10px;' type='submit' name='Login' value='Login' />
    </form>
    ";
    }
    
    elseif (isset($_SESSION['SESS_MEMBER_ID'])){
    include 'Login/member-index.php';
    }
    ?>
    

  10. Well, I won't flesh it out, but I can give you a concept to work with.  Make it so your SWF files "call home", and saves the environment data to a table, then image magik can create the images server side (heavy coding, not for a novice).  You would need to keep track of all data for this to work. background, x and y coords for every item on the doll, etc.  Then you can have image magik draw one item on to the background, using the x and y coords. I can't help much past that, but....hope this has helped. ( repeated myself there, but I wanted to expound)

  11. use this code on all your user pages (pages that you may be redirecting back to):

    <?php
    session_start();
    $host = $_SERVER['HTTP_HOST'];
    $self = $_SERVER['PHP_SELF'];
    $query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
    $url = !empty($query) ? "http://$host$self?$query" : "http://$host$self";
    $_SESSION['history'] = $url;
    
    
    /* Place rest of page below */
    

    Now, when you want to redirect them back:

     

    <?php
    session_start();
    /* Your stuff here, without any output, or you can't do a header redirect */
    
    header("location:".$_SESSION['history']);
    

  12. <?php
    $editFormAction = $_SERVER['PHP_SELF'];
    if ($_GET['go'] == "post_data"){
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "referral")) {
      $insertSQL = sprintf("INSERT INTO referring_website (referalid) VALUES (%s)",
                           GetSQLValueString($_POST['referral'], "int"));
    
    	 mysql_select_db($database_admin, $admin);
    	 $Result1 = mysql_query($insertSQL, $admin) or die(mysql_error());
    
    	 $insertGoTo = "index.php";
    	 if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    	   $insertGoTo .= $_SERVER['QUERY_STRING'];
    	 }
    	 header("location:?go=complete");
    }
    
    
    }
    if ($_GET['go'] == "complete"){
    			print "<center><strong><p>thank you for submitting</p></strong></center>";
    		}
    ?>
    
    <form id="referral" name="referral" method="POST" action="<?php echo $editFormAction; ?>?go=complete">
            <table width="76%" border="0">
    		<tr>
            		<td width="43%"><div align="right">ThomasNet</div></td>
                	<td width="57%"> <div align="center">
                  	<input type="radio" name="referral" id="referral" value="2" />
                	</div></td>
              	</tr>
              	<tr>
                	<td><div align="right">Google</div></td>
                	<td><div align="center">
                  	<input type="radio" name="referral" id="referral2" value="1" />
                	</div></td>
              	</tr>
              	<tr>
                	<td><div align="right">Directly</div></td>
                	<td><div align="center">
                  	<input type="radio" name="referral" id="referral3" value="3" />
                	</div></td>
              	</tr>
            </table>
            <br />
            <input type="submit" name="submit" id="submit" value="Submit" />
            <input type="hidden" name="MM_insert" value="referral" />
    </form>
    

     

    From what I can see, this should work fine. <I hope>

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