Jump to content

jrws

Members
  • Posts

    124
  • Joined

  • Last visited

    Never

Posts posted by jrws

  1. Hey guys,

    Coding something for a survey as no solution exists for our needs. I have not finished the code as I still need to do error checks + making it spam proof. Anyway I am not reciving the email even though it says that I have been sent it.

    Any suggestions are appreciated, please ask if you need additional info to be able to help, and thank you in advanced.

     

     

    <?php
    error_reporting(0);
    if(isset($_POST['submit'])){
    //Check that all fields that are mandatory are filled in and that the $Email variable is real
    $Title = $_POST['Title'];
    $FirstName = $_POST['FirstName'];
    $LastName = $_POST['LastName'];
    $Email= $_POST['Email'];
    $Country= $_POST['Country'];
    $State= $_POST['State'];
    $List= $_POST['List'];
    $Nav= $_POST['Nav'];
    $IssuesYes= $_POST['IssuesCheck'];
    $IssuesList= $_POST['IssuesList'];
    $Satisfaction= $_POST['Satisfaction'];
    $Improvement= $_POST['Improvement'];
    $ValueSatisfaction= $_POST['Value'];
    $Recommendation= $_POST['Recommend'];
    $Knowledge= $_POST['Knowledge'];
    $Comments= $_POST['Comments'];
    $Gender= $_POST['Gender'];
    $Age= $_POST['Age'];
    $Source= $_POST['Source'];
    $ContactNumber= $_POST['Contact'];
    $Newsletter= $_POST['Newsletter'];
    $errors = array();
    //Check that the fields above are not empty:
    
    $to = "email@email.com";//Obviously not real one that I am sending to.
    $subject = "Survey Form Submission";
    $from = $to;
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
    $body = "$name submitted the survey form:\n".
        "This is what they responded with to each question: <br>".
    "Their Name: $Title $FirstName $LastName <br>"."Email: $Email <br>"."Country: $Country <br>"."State: $State<br>"."Bought: $List<br>"."Website Navigation: $Nav<br>"."Issues: $IssuesYes " ." $IssuesList"."Satisfaction: $Satisfaction<br>"."Improvement: $Improvement<br>"."Value Satisfaction: $ValueSatisfaction<br>"."Reccomend: $Recommendation<br>"."Knowledge: $Knowledge<br>"."Comments: $Comments <br>"."Gender: $Gender<br>"."Age: $Age <br>"."Source for Finding Us: $Source <br>"."Contact: $ContactNumber<br>"."Subscribe to Newsletter?: $Newsletter<br>";
        $headers = "From: $from \r\n";
        $headers .= "Reply-To: $visitor_email \r\n";
       if( mail($to, $subject, $body,$headers)){
       echo "Email Send!";
       }else{
       echo "Somethings wrong :\ ";
       }
    
       // header('Location: http://www.********/thank-you-for-survey');
    }
    
    
    ?>

  2. So a project I have simply to learn how it is done is to make an auto updating sitemap with a auto submitter. I have been doing a little research on sitemaps but haven't found much in the way of a tutorial or white paper or similar, anyway I was wondering if I am on the right track or not.

     

    What I was thinking for the auto-updating sitemap is since site maps are XML, when an article is published using my custom CMS/Blogging system, I make it rewrite the sitemap appending the new URL that will be generated.

     

    Then for the auto-submit, I can either make it a cron job or just manual press, but it would go though a for list of URLs, replacing the end part with my site map url. I think that is how it would be done.

     

    If you have a better idea, or can point out an article so I can understand a lot more with sitemaps, I will appreciate it, I am trying to learn as much as possible, I have gone to the offical website (sitemaps.org) but it doesn't have what I am looking for.

     

    Thanks,

     

    James

  3. Hey there,

    What I am talking about is something similar to Aweber, I currently cannot afford their fee's so I was wondering how I can set up a mailing list so that I preprogram messages to be sent on a certain date. I think I would be using a database to store the messages, but I am not sure how to go on beyond there. Also in addition I would like to know (for learning purposes) how wordpress sets this up for their posting software, where you are able to line up articles to be posted on several different days.

     

    Cheers,

    James

  4. Hey guys,

    I have been programming for a while and I want to know what sort of design patterns I should look into when making a game?

    For example what design pattern is best for:

    Database management

    User management

    Forum management

    Etc

    I can only think of singleton or factory (for user/forum)

    I am reasonably new to OOP, but would like to learn it properly, so I thought creating a simple program such as rock-paper-siccors would work to be able to expand it eventually, and hopefully it will teach me reusable code practice.

  5. Hey there,

     

    That topic may be a little confusing to begin with so let me explain.

     

    I know how to make this url-> www.example.com/articles?id=1 into www.example.com/articles/1

     

    But how would I extract the topic so instead of a number it is the title? Would I need to change what is extracted from the database? Cause I extract articles based on their IDs, but I want the URL to reflect their titles. Is that possible?

     

    I hope I have made sense, I don't really have any code to show, but if I can clarify on something, please ask and I will try.

     

     

    Thanks,

     

    James

  6. Hey there,

    I have made a custom forum and so far so good, I was wondering how I can make the topics become 'stickyed' and stay at the top of the page? Would I need a new row on the topic table? What about locking, I am thinking only access levels can post. Or something like that.

    Any help is appreciated,

    Thanks,

    James.

  7. Hey there,

    I thought I had sufficent protection from crashes, but evidently not,

    When I edit news, wich is a simple UPDATE query I get the error:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'etty princess )rnseernitrndoesrnitrnwhenrnirntryrntornwriternlikernthis.' WHER' at line 1

    etc

    However I have protected the input by using this function:

    <?php
    function clean($string)
    {
        if (get_magic_quotes_gpc())
        {
            $string = stripslashes($string);
        } elseif (!get_magic_quotes_gpc())
        {
            $string = addslashes(trim($string));
        }
        $string = trim($string);
        //$string = escapeshellcmd($string);//Uncomment if the website uploading to allows this.
        $string = mysql_real_escape_string($string);
        $string = stripslashes(strip_tags(htmlspecialchars($string)));
        return $string;
    }?>

    So, why am I returning an error?

    Do you want to/need to see the edit page?

    EDIT: I was wanting to know why it doesn't escape from the entered data, I have made sure I sercured it..

  8. Hey there guys,

    I am currently working on a project for someone, and I have run into a little spot, nothing that will destroy the project but something annoying nonetheless.

    So what happens is I wipe my table to test that everything is working and continually when I sign up the first user it inserts an empty row looking like this:

    id 	u_id 	stat_id 	value
    1 	0 	5 	0
    

    And I can't seem to see where in my code this is happening:

    Register.php

    <?php 
    session_start(); 
    if($_SESSION['loggedin'] == 'yes')
    {
    echo'<body bgcolor="#000000"><script>location.replace("members.php");</script>';
    }
    else
    {
    $title="Register"; 
    include("includes/header.php"); 
    ?>
    <body><center>
    
    <table cellpadding="0" cellspacing="0" class="mainborder">
    <tr><td>
    <table cellpadding="0" cellspacing="0" border="0">
    
    <tr>
    <td class="title"></td>
    </tr>
    
    <tr>
    <td class="navigation">
    <? include("includes/navigation.php"); ?>
    </td>
    </tr>
    
    <tr>
    <td class="content"><center>
    
    
    <!----------------------------------------------------------->
    <form method="POST" action="register.php">
    
    <table cellpadding="0" cellspacing="1" border="0">
    <tr>
    
    <td colspan="3" class="registerheader">Registration Form</td>
    
    </tr><tr class="light">
    
    <td colspan="3" class="registerinfo">
    <!--------------------------------------------------------->
    
    <?php
    
    $fullname=clean($_POST['fullname']);
    $age=clean($_POST['age']);
    $email=clean($_POST['email']);
    $player=clean($_POST['username']);
    $password=clean($_POST['password']);
    $password2=clean($_POST['password2']);
    $regdate=clean($_POST['regdate']);
    $ip=clean($_SERVER['REMOTE_ADDR']); 
    
    $isplayer="SELECT * from users where username='$player'";
    $isplayer2=mysql_query($isplayer) or die("");
    $isplayer3=mysql_fetch_array($isplayer2);
    
    $isemail="SELECT * from users where email='$email'";
    $isemail2=mysql_query($isemail) or die("not able to query for email");
    $isemail3=mysql_fetch_array($isemail2);
    
    if($fullname == '' && $age == '' && $player == '')
       {
        echo 'Please enter your details correctly below to register.';
       }
    // Check to see if they have left the username field blank /////////////////////////////////////////////
    else if(strlen($player)<1)
       {
        echo 'Please enter a username.<br />';
       }
    // Check to see if they have entered a username less than 4 characters ////////////////////////////////////////////////
    else if(strlen($player)<4)
       {
        echo 'Your username must be longer than 4 characters.<br />';
       }
    // Check to see if the username given is already being used ////////////////////////////////////////////
    else if($isplayer3)
       {
        echo 'Somebody already has that username.<br />';
       }
    ////////////////////////////////// Check For Fullname Field ////////////////////////////////////////////
    // Check to see if they have left the fullname field blank /////////////////////////////////////////////
    else if(strlen($fullname)<1)
       {
        echo 'Please enter your fullname.<br />';
       }
    // Check to see if there full name is less than 5 letters long /////////////////////////////////////////
    else if(strlen($fullname)<5)
       {
        echo 'If you fullname is less than 5 letters long, please contact an Admin.<br />';
       }
    ////////////////////////////////// Check For Age Field /////////////////////////////////////////////////
    // Check to see if they have left the age field blank //////////////////////////////////////////////////
    else if(strlen($age)<1)
       {
        echo 'Please enter your age.<br />';
       }
    // Check to see if they have left the age field blank //////////////////////////////////////////////////
    // Check to see if they are 8 years old or over ////////////////////////////////////////////////////////
    else if($age < '8')
       {
        echo 'You must be at least 8 years old to play.<br />';
       }
    ////////////////////////////////// Check For Email Field ///////////////////////////////////////////////
    // Check to see if they have left the email field blank ////////////////////////////////////////////////
    else if(strlen($email)<1)
       {
        echo 'Please enter your e-mail address.<br />';
       }
    // Check to see if they have enter a valid length email ////////////////////////////////////////////////
    else if(strlen($email)<5)
       {
        echo 'Please enter a valid e-mail address.<br />';
       }
    else if($isemail3)
       {
        echo 'That e-mail address is already in use.';
       }
    ////////////////////////////////// Check For Password Field ////////////////////////////////////////////
    // Check to see if they have left the password field blank /////////////////////////////////////////////
    else if(strlen($password)<1)
       {
        echo 'Please enter a password.<br />';
       }
    // Check to see if they have entered a sercure password longer than 4 characters ///////////////////////
    else if(strlen($password)<4)
       {
        echo 'Your password must be longer than 4 characters for sercurity reasons.<br />';
       }
    // Check to see if they have left the re-type password field blank /////////////////////////////////////
    else if(strlen($password2)<1)
       {
        echo 'Please re-type your password.<br />';
       }
    // Check to see if they have entered a sercure re-typed password longer than 4 characters //////////////
    else if(strlen($password2)<4)
       {
        echo 'Please re-type your password correctly.<br />';
       }
    // Check to see if they have entered a sercure re-typed password longer than 4 characters //////////////
    else if($password != $password2)
       {
        echo 'Please re-type your password correctly.<br />';
       }
    // All input is valid so register the user so they can login ///////////////////////////////////////////
    else
       { 
       //Set the stats:
       	$password = sha1($password);
    $SQL = "INSERT into users(fullname, age, email, username, password, ip, regdate) VALUES ('$fullname', '$age', '$email', '$player', '$password', '$ip', '$regdate')"; 
    mysql_query($SQL) or die("could not register");
    $userID = mysql_insert_id();
    setStat('Turns',$userID,100);
    setStat('Cash',$userID,100);
    setStat('Followers',$userID,100);
    setStat('Attack',$userID,100);
    setStat('Health Points',$userID,100);
    setStat('defense',$userID,100);
    setStat('attacks_in',$userID,100);
    setStat('attacks_out',$userID,100);
    setStat('total_attacks_in',$userID,100);
    setStat('total_attacks_out',$userID,100);
    setStat('exp',$userID,100);
    setStat('rem_exp',$userID,100);
    setStat('Current Level',$userID,100);
    $message="Hey ".$player.",<br>Just to say a quick hello to you.<br>Hello! <br><br>If you need any help or get stuck post on the forums or send me a message and you will be replied to as soon as possible.<br><br>Thanks for reading and joining,<br><br>Storm Trooper";
    
    $date=date("M jS, Y");
    $time=date("g:i:s a");
    
    $SQL2 = "INSERT into messages(recipient, sender, subject, message, date_sent, time_sent) VALUES ('$player', 'Soulstealer', 'Welcome to New Core', '$message', '$date', '$time')"; 
    mysql_query($SQL2) or die("could not register");
    ?>
    Registration successful, you may now login.
    <? }
    ?>
    
    <!--------------------------------------------------------->
    </td>
    
    </tr><tr class="dark">
    
    <td class="registertype">Fullname</td>
    <td class="registerspacer">:</td>
    <td class="registerinput"><input class="input" type="text" name="fullname" size="25" value="<?=$fullname?>"></td>
    
    </tr><tr class="light">
    
    <td class="registertype">Age</td>
    <td class="registerspacer">:</td>
    <td class="registerinput"><input class="input" type="text" name="age" size="25" value="<?=$age?>" onkeyup="valid(this,'notnumbers')" onblur="valid(this,'notnumbers')"></td>
    
    </tr><tr class="dark">
    
    <td class="registertype">E-mail</td>
    <td class="registerspacer">:</td>
    <td class="registerinput"><input class="input" type="text" name="email" size="25" value="<?=$email?>"></td>
    
    </tr><tr class="light">
    
    <td class="registertype">Username</td>
    <td class="registerspacer">:</td>
    <td class="registerinput"><input class="input" type="text" name="username" size="25" value="<?=$_POST['username'];?>" onkeyup="valid(this,'special')" onblur="valid(this,'special')"></td>
    
    </tr><tr class="dark">
    
    <td class="registertype">Password</td>
    <td class="registerspacer">:</td>
    <td class="registerinput"><input class="input" type="password" name="password" size="25" mask="x" onkeyup="valid(this,'quotes')" onblur="valid(this,'quotes')"></td>
    
    </tr><tr class="light">
    
    <td class="registertype">Re-type Password</td>
    <td class="registerspacer">:</td>
    <td class="registerinput"><input class="input" type="password" name="password2" size="25" mask="x" onkeyup="valid(this,'quotes')" onblur="valid(this,'quotes')"></td>
    
    </tr>
    <input type="hidden" name="regdate" size="25" value="<?=date('M d, Y')?>">
    
    <tr>
    
    <td colspan="3" class="registerbutton"><input class="input" type="submit" value="Register" name="submit"></td>
    
    </tr>
    
    </table>
    
    
    <!----------------------------------------------------------->
    
    <br /><br/></center></td></form>
    </tr>
    <tr>
    
    <td class="otherlinks">
    <? include("includes/otherlinks.php") ?>
    </td>
    </tr>
    
    <tr>
    <td class="footer">
    <? include("includes/footer.php") ?>
    </td>
    </tr>
    
    </table>
    </td></tr></table>
    </center></body>
    </html>
    
    <? } ?>

    Functions.php

    <?php
    include_once("includes/connect.php");
    function getStat($statName,$userID) {
    createIfNotExists($statName,$userID);
    $query = sprintf("SELECT value FROM user_stats WHERE stat_id = (SELECT id FROM stats WHERE display_name = '%s' OR short_name = '%s') AND u_id = '%s'",
    	clean($statName),
    	clean($statName),
    	clean($userID));
    $result = mysql_query($query);
    list($value) = mysql_fetch_row($result);
    return $value;		
    }
    function setStat($statName,$userID,$value) {
    createIfNotExists($statName,$userID);
    $query = sprintf("UPDATE user_stats SET value = '%s' WHERE stat_id = (SELECT id FROM stats WHERE display_name = '%s' OR short_name = '%s') AND u_id = '%s'",
    	clean($value),
    	clean($statName),
    	clean($statName),
    	clean($userID));
    $result = mysql_query($query);
    }
    
    function createIfNotExists($statName,$userID) {
    $query = sprintf("SELECT count(value) FROM user_stats WHERE stat_id = (SELECT id FROM stats WHERE display_name = '%s' OR short_name = '%s') AND u_id = '%s'",
    	clean($statName),
    	clean($statName),
    	clean($userID));
    $result = mysql_query($query);
    list($count) = mysql_fetch_row($result);
    if($count == 0) {
    	// the stat doesn't exist; insert it into the database
    	$query = sprintf("INSERT INTO user_stats(stat_id,u_id,value) VALUES ((SELECT id FROM stats WHERE display_name = '%s' OR short_name = '%s'),'%s','%s')",
    	clean($statName),
    	clean($statName),
    	clean($userID),
    	'0');
    	mysql_query($query);
    }	
    }
    ?>

  9. Thanks for clearing that up,

    I have tried that, however now the rewrite wont work, I get a 404, the only thing I changed was the absolute as you suggested, I have not edited the .htaccess file. So I am stuck, and I have no idea as to why this would happen.

    But thank you, hopefully the bloody thing will work again.

    -James-

  10. Hey guys,

    I have recently stumbled across this, I understand how to use mod_rewrite and I am happy, however:

    When I use the new shorter url I have no styling or javascript. Although the link to the style sheet and javascript show, neither work. What do I do?

    Here is the header file:

    <?php
    require_once ('libary/config.php');
    require_once ('libary/functions.php');
    //Header
    session_start();
    ob_start();
    error_reporting(1);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head><title><?= $title . '---' . $siteName; ?></title>
    <link rel="stylesheet" type="text/css" href="./libary/default.css">
    <script type = "text/javascript" src="./libary/main.js"></script>
    </head>
    <body>
    <?
    
    if (isset($_COOKIE['username']) && isset($_COOKIE['u_level']) && isset($_COOKIE['u_id']) &&
        isset($_COOKIE['password']))
    {
        //$id = $_COOKIE['u_id'];
        $sql = "SELECT username AND password FROM user WHERE username = '{$_COOKIE['username']}'AND  password ='{$_COOKIE['password']}'";
        $result = mysql_query($sql) or die(mysql_error());
        //$row = mysql_fetch_array($result);
        if (mysql_num_rows($result) == 1)
            //If the username and password combination exist set the sessions
    
        {
            $_SESSION['username'] = $_COOKIE['username'];
            $_SESSION['u_level'] = $_COOKIE['u_level'];
            $_SESSION['u_id'] = $_COOKIE['u_id'];
            $_SESSION['password'] = 1;
            //echo 'Success';
        } else
        {
           header('Location: '.$siteURL.'logout.php');
       exit();
        }
    }
    if (isset($_SESSION['username']) && $_SESSION['password'] == 1 && $_SESSION['u_level'] ==
        6)
    {
    ?><div class="holder">
    <div id="header">
    
    |<a href="<?= $siteURL; ?>">Home</a>|
    <a href="<? $siteURL; ?>new_news.php">Post news</a>|
    <a href="<? $siteURL; ?>view_news.php">View all the news</a>|
    <a href="<? $siteURL; ?>admin.php">Admin page</a>|
    <a href="<? $siteURL; ?>profile.php?id=<?= $_SESSION['u_id']; ?>">Your profile</a>|
    <a href="<? $siteURL; ?>profile.php">All profiles</a>|
    <a href="<?= $siteURL; ?>logout.php" onClick="return verify('Are you sure you want to logout?')" >Logout</a>|
    </div>
    
    <?
    } elseif (isset($_SESSION['username']) && $_SESSION['password'] == 1)
    { ?>
    <div class="holder">
    <div id="header">
    |<a href="<?= $siteURL; ?>">Home</a>|
    <a href="<?= $siteURL; ?>new_news.php">Post news</a>|
    <a href="<?= $siteURL; ?>view_news.php">View all the news</a>|
    <a href="<?= $siteURL; ?>profile.php?id=<?= $_SESSION['u_id']; ?>">Your profile</a>|
    <a href="<?= $siteURL; ?>profile.php">All profiles</a>|
    <a href="<?= $siteURL; ?>logout.php" onClick="return verify('Are you sure you want to logout?')">Logout</a>|
    
    </div><?
    } else
    {
    ?>
    <div class="holder">
    <div id="header">
    |<a href="<?= $siteURL; ?>">Home</a>|
    <a href="<?= $siteURL; ?>login.php">Login</a>|
    <a href="<?= $siteURL; ?>register.php">Register</a>|
    <a href="<?= $siteURL; ?>view_news.php">View all the news</a>|
    
    </div>
    
    <?
    }
    ?>

    Here is the .htaccess:

    #.htaccess
    RewriteEngine On # Turn on the rewriting engine
    RewriteRule ^news/?$ view_news.php [NC,L] # Handle news requests
    RewriteRule ^news/([0-9]+)/?$ view_news.php?=$1 [NC,L] # Handle news requests

    Note that the first one includes the style sheet and css, the second one doesn't.

    BTW here is the output from the second one:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head><title>News---Doonside Technology High</title>
    <link rel="stylesheet" type="text/css" href="./libary/default.css">
    <script type = "text/javascript" src="./libary/main.js"></script>
    </head>
    <body>
    <div class="holder">
    <div id="header">
    |<a href="http://localhost/school%20site/">Home</a>|
    <a href="http://localhost/school%20site/login.php">Login</a>|
    <a href="http://localhost/school%20site/register.php">Register</a>|
    
    <a href="http://localhost/school%20site/view_news.php">View all the news</a>|
    
    </div>
    
    <b>Test</b><br />Test<br /><a href="?id=1">View this post</a><br/><br><b>TEst</b><br />Test<br /><a href="?id=2">View this post</a><br/><br> [<b>1</b>] <div id="footer">
    19 April 2009 6:07:48 PM<br><small>Powered By Kardaina Entertainment©</small></div>
    
    </div>
    </body>
    </html>
    

    Please help, and thanks for your time;

    -James-

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