Jump to content

Eggzorcist

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

Posts posted by Eggzorcist

  1. here's the PHP code.

     

    <?php
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "tgj4u";
    
    
    mysql_connect($dbhost, $dbuser, $dbpass);
    mysql_select_db($dbname) or die(mysql_error());
    $id =  $_GET['id'];
    $id = mysql_real_escape_string($id);
    $query = "SELECT * FROM maildata WHERE id = '$id'";
    $qry_result = mysql_query($query);
    
    
    
    if (mysql_num_rows($qry_result)){
    
    
    while($info = mysql_fetch_assoc($qry_result)){
    
    echo "Sent by: " . $info['sender'] . "<br>";	
    echo "Recipient: " . $info['recipient'] . "<br>";	
    echo "Departed: " . $info['depart'] . "<br>";
    echo "Satus: " . $info['depart'] . "<br>";
    echo "Current Location: " . $info['currentlocation'] . "<br>";
    echo "Arrival Location: " . $info['finallocation'] . "<br>";
    echo "Expected on: " . $info['expected'] . "<br>";
    
    }
    }
    
    else
    {
       echo "<p>No data was found with that ID.</p>\n";
    }
    
    
    
    
    
    ?>
    
    

     

    I've tried with both mizila firefox and internet explorer.

  2. Alright, heres my JS code. All works but one thing. It seems like my PHP code isn't receiving any GET information but I'm having trouble seeing how it isnt.

     

     

    // JavaScript Document
    
    var xmlhttp;
    
    function showUser(str)
    {
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
      {
      alert ("Browser does not support HTTP Request");
      return;
      }
    var url="trackeractions.php";
    url=url+"?id="+str;
    //url=url+"&sid="+Math.random();
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
    }
    
    function stateChanged()
    {
    if (xmlhttp.readyState==4)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
    }
    
    function GetXmlHttpObject()
    {
    if (window.XMLHttpRequest)
      {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      return new XMLHttpRequest();
      }
    if (window.ActiveXObject)
      {
      // code for IE6, IE5
      return new ActiveXObject("Microsoft.XMLHTTP");
      }
    return null;
    }

     

     

     

    I'm not that good in AJAX. This is for my media design class.

     

     

    Thanks

  3. Here is my code:

     

    <?php
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "tgj4u";
    
    
    mysql_connect($dbhost, $dbuser, $dbpass);
    
    mysql_select_db($dbname) or die(mysql_error());
    $id = $_GET['id'];
    $id = mysql_real_escape_string($id);
    $query = "SELECT * FROM maildata WHERE id = '$id'";
    
    
    
    if ($qry_result = mysql_query($query) or die(mysql_error())){
    
    
    while($info = mysql_fetch_array($qry_result)){
    
    echo "Sent by: " . $info['sender'] . "<br>";	
    echo "Recipient: " . $info['recipient'] . "<br>";	
    echo "Departed: " . $info['depart'] . "<br>";
    echo "Satus: " . $info['depart'] . "<br>";
    echo "Current Location: " . $info['currentlocation'] . "<br>";
    echo "Arrival Location: " . $info['finallocation'] . "<br>";
    echo "Expected on: " . $info['expected'] . "<br>";
    
    }
    
    
    }
    
    
    
    ?>

     

     

    What I am trying to do is from the ID get information in maildata, but for some reason the while command isnt working and if I dont have while all I get from the echos is the text not the variables.

     

    Also if I were to add that if it doesnthave that ID to echo out something how could I do tht?

     

     

    thanks

  4. I downloaded firebug but coudnt seem to find the mistake.

     

    So far all its doing is refreshing the page and adding the ?id=55583&ID=Track to the url

     

    I'm unsure why ID=Track and I am not seeing any echo thats within my php document for some reason.

  5. I don't get any visual error but when I click submit it does "error on page" at the bottom info of the browser where it normally says the status of that loads the page or "done" status.

     

     

    The PHP does not yet work fully independantly, however, it does show information independantly just not the query information but everything else does.

  6. I'm trying to make a form which will using ajax get information through php and sql and will display that information Ajax style but I'm currently getting an error.

     

    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <LINK REL=stylesheet HREF="stylesheet.css" TYPE="text/css">
    </head>
    
    <body>
    
    
    <script language="javascript" type="text/javascript">
    
    <!-- 
    //Browser Support Code
    function ajaxFunction(){
    var ajaxRequest;  
    try{
    	ajaxRequest = new XMLHttpRequest();
    } catch (e){
    
    	try{
    		ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try{
    			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    
    		} catch (e){
    
    			alert("Your browser broke!");
    			return false;
    		}
    	}
    }
    
    ajaxRequest.onreadystatechange = function(){
    	if(ajaxRequest.readyState == 1){
    		document.myForm.time.value = ajaxRequest.responseText;
    	}
    }
    var id = document.getElementById('id').value;
    var queryString = "?id=" + id;
    ajaxRequest.open("GET", "trackeractions.php" + queryString, true);
    ajaxRequest.send(null); 
    
    
    }
    
    //-->
    </script>
    
    
    <div class='wrap'>
    <p><img src="images/logo.png" width="190" height="29" /><br />
    </p>
    <div class="nav">Home</div>
    <div class="nav2">Services</div>
    <div class="nav2">About Us</div>
    <div class="nav2">Customer Support</div>
    <div class="nav2">Tracker</div>
    <div class="spacer"></div>
    <div class="title">
      <div class="textle">Price & Services </div>
    </div>
    <div class='picture'><img src="images/cargo.png" alt="cargoplane" width="450" height="199" /></div>
    
    <div class='content'>
    
    Package ID:<input name="id" type="text" value="" size="10" maxlength="10" /> <br />
    <input type='button' onclick='ajaxFunction()' value='Track' />
    
    </div>
    
    
    </div>
    </body>
    </html>
    

     

    php file

     

    <?php
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "tgj4u";
    //Connect to MySQL Server
    mysql_connect($dbhost, $dbuser, $dbpass);
    //Select Database
    mysql_select_db($dbname) or die(mysql_error());
    // Retrieve data from Query String
    $id = $_GET['id'];
    // Escape User Input to help prevent SQL Injection
    $id = mysql_real_escape_string($id);
    //build query
    $query = "SELECT * FROM maildata WHERE id = '$id'";
    
    //Execute query
    $qry_result = mysql_query($query) or die(mysql_error());
    
    // Insert a new row in the table for each person returned
    $info = mysql_fetch_array($qry_result)
    
    echo "Sent by: " . $info['sender'] . "<br>";	
    echo "Recipient: " . $info['recipient'] . "<br>";	
    echo "Departed: " . $info['depart'] . "<br>";
    echo "Satus: " . $info['depart']; . "<br>";
    echo "Current Location: " . $info['currentlocation'] . "<br>";
    echo "Arrival Location: " . $info['finallocation'] . "<br>";
    echo "Expected on: " . $info['expected'] . "<br>";
    
    
    ?>
    

     

    I've tried alot of things, but I dont see where the error is...

     

     

    Thanks

  7. I made a script in which registrates a user very basicly. here are the functions used.

     

    I click submit get no error but it doesnt do anything to the databse nor does it send me the the url as indicated in the header();

     

     

    <?php
    require_once('config.php');
    
    function secure_var($var){
    
    $var = mysql_real_escape_string(htmlentities($var));
    
    }
    
    function check_username($username){
    
    $query = mysql_query("SELECT * FROM user_info WHERE username = {$username}");
    
    if ($query >= 1){
    
    return true;
    
    }
    
    else {
    
    return false; }
    
    }
    
    
    function check_email($email){
    
    $query = mysql_query("SELECT * FROM user_info WHERE email = {$email}");
    
    if ($query >= 1){
    
    return true;
    
    }
    
    else {
    
    return false; }
    
    
    }
    
    
    // Register User
    function register_user($username, $password1, $password2, $email, $captcha){
    
    secure_var($username);
    secure_var($password1);
    secure_var($password2);
    secure_var($email);
    
    $Error = null;
    
    // Validate Username Field
    if(!preg_match("/\A[a-z0-9_]{4,15}$/i",$username)){
    	$Error .= "Username Can Only Contain Letters, Numbers and Underscores (Between 4-15 Characters Long) <br />";
    }
    
    // Validates Username Availability
    if(check_username($username) == true){
    
    $Error .= "You're chosen username is taken. Plase choose another one.<br />";
    
    }
    
    // Validates Email Availability
    if (check_email($email) == true){
    
    $Error .= "You're email is already in use.<br />";
    
    } 
    
    // Validate Password Field
    if (!preg_match("/\A[a-z0-9 _-]{4,15}$/i",$password1)){
    	$Error .= "Password Can Only Contain Letters, Numbers, And Underscores (Between 4-15 Characters Long <br />";
    }
    
    // Validate Password Confirmation
    if ($password1 != $password2){
    	$Error .= "Password and Password Confirmation Do Not Match <br />";
    }
    
    // Validate Email Address Format
    if (!preg_match("/\A[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/", $email)){
    	$Error .= "Email Address Must Be In format: [username]@[domain].[extension] <br />";
    }
    
    // Validate Security Image
    if ($captcha != $_SESSION['captcha']){
    	$Error .= "Your Captcha Input Does Not Match The Image Shown";
    }		
    
    // Result Success or Error
    if($Error == null){
    
    
    	$reg_user = mysql_query("INSERT INTO user_info (username, password, email) VALUES ($username, $password, $email)");
    
    	if($reg_user){
    	header('login.php?reg=1');
    	}
    
    }else{
    	// Echo the error(s)
    	echo($Error);
    }
    }
    ?>

  8. still not responding...

     

    <?php
    require_once("functions.php");
    
    if (isset($_POST['post_form'])){
    register_user($_POST['username'], $_POST['password1'], $_POST['password2'], $_POST['email'], $_POST['securityCode']);
    }
    ?>
    
    
    <p>Username: 
      <label>
      <input name="username" type="text" id="username" maxlength="15" />
      </label>
    </p>
    <p>
      Password: 
      <label>
      <input type="password" name="password1" id="password1" />
        </label>
      </p>
    <p>
      Re-type Password: 
      <label>
      <input type="password" name="password2" id="password2" />
        </label>
      </p>
    <p>
      E-mail: 
      <label>
      <input type="text" name="email" id="email" />
        </label>
    </p>
    <p>  <img src="captcha/captcha.php" alt="captcha" /><br />
      Security Code: 
      <label>
      <input name="securityCode" type="text" id="securityCode" maxlength="5" />
      </label>
    </p>
    <p>
      <label>
      <input type="submit" name="post_form" id="post_form" value="Submit" />
      </label>
    </p>
    

  9. I'm not sure why my capcha session is null when I try to echo it nothing shows up.

     

    <?php
    
    $length = 5;
    $width = 150;
    $height = 50;
    
    //Creates md5 hash
    $hash = md5(rand(0, 9999));
    
    //creates a code with $length  
    $code = substr($hash, 15, $length);
    
    //stores the code into a session
    $_SESSION['captcha'] = $code;
    
    
    //creates the image
    $image = imagecreate($width, $height); 
    
    //creates background and text colours
    $background = imagecolorallocate($image, 0, 0, 0);
    $text = imagecolorallocate($image, 255, 255, 255);
    
    //creates the image
    imagefill($image, 0, 0, $background); 
    
    //Specifies font and text
    imagettftext($image, 42, 8, 12, 60, $text, "captcha.ttf", $code);
    
    //Tells the browser what kind of image is being outputted. 
    header("Content-Type: image/png"); 
    
    //creates the image
    imagepng($image);
    
    //frees up resources
    imagedestroy($image); 
    
    ?>

     

    this is how i included it.

    <img src="captcha/captcha.php" alt="captcha" />

     

     

  10.  

    I don't understand, I leave everything blank and it passes and echo's out it should register the user.... Why is my regex not working?

     

    function register_user($username, $password1, $password2, $email, $captcha){
    
    
    	if (!preg_match('/^[a-z\d_]{4,15}$/i',$username)){
    		$usernameError = true;
    	}
    
    	if ($password1 != $password2){
    		$passwordError = true;
    	}
    
    	if (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/', $email)){
    		$emailError = true;
    	}
    
    	if ($captcha != $_SESSION['captcha']){
    		$captchaError = true;
    	}		
    
    
    	if ($usernameError == true or !isset($passwordError) or !isset($emailError) or !isset($captcha)){
    		//Register the user
    		echo "will register the user";
    	}
    
    
    	else {
    
    		if ($usernameError == true){
    		echo "You're username is not formatted properly.<br>";
    		}
    		if ($passwordError == true){
    		echo "You're entered passwords do not match<br>";
    		}
    		if ($emailError == true){
    		echo "Please enter a correct e-mail adress.<br>";
    		}
    		if ($captchaError == true){
    		echo "Security code did not match.<br>";
    		}
    	}
    
    }

  11. I have one major issue with my captcha, It's doing everything I want it to but one thing.

    I thinks its alone on the page and makes my register.php a png image and outputting nothing else but itself.

     

    heres my code:

    <?php
    function create_captcha($length){
    
    //Creates md5 hash
    $hash = md5(rand(0, 9999));
    
    //creates a code with $length  
    $code = substr($hash, 15, $length);
    
    //stores the code into a session
    $_SESSION['captcha'] = $code;  
    
    //image size
    $width = 150;
    $height = 50;
    
    //creates the image
    $image = imagecreate($width, $height); 
    
    //creates background and text colours
    $background = imagecolorallocate($image, 0, 0, 0);
    $text = imagecolorallocate($image, 255, 255, 255);
    
    //creates the image
    imagefill($image, 0, 0, $background); 
    
    //Specifies font and text
    imagettftext($image, 42, 5, 15, 55, $text, "captcha.ttf", $code);
    
    //Tells the browser what kind of image is being outputted. 
    header("Content-Type: image/png"); 
    
    //creates the image
    imagepng($image);
    
    //frees up resources
    imagedestroy($image); 
    }
    ?>

     

    thanks

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