Jump to content

Asheeown

Members
  • Posts

    471
  • Joined

  • Last visited

Posts posted by Asheeown

  1. Obviously it's not successfully getting through

    try registering a session by first putting this at the very top of your page or in a page that your going to include:

    [code]
    <?php
    session_start();
    header("Cache-control: private");
    ?>
    [/code]
    Then register any old session like so
    [code]
    $_SESSION['Test'] = "TestVariables";
    [/code]
  2. Your probably not an organizer but in my code this is how i would set something up to keep track of it:

    [code]

    <?php

    if(blahblahblah) {
        DO STUFF
    } else {
        DO OTHER STUFF
    } // End of if(blahblahblah)
    ?>
    [/code]

    label your closings so you know if you closed something or not...use your tab key spread functions out....organize it a bit put things you open on one line the closing on the same and anything you open in between tab once before you do it
  3. See where you want to start is take a page throw a form on there with say the name of your game then with your sessions or however you keep track of who is logged on call him from the database and select what league he is in...then call every user from that league and string a drop down box.  basically its going to go to the page you specify with the form values which you can insert as a pending request in the database and when a user logs on he/she can simply confirm it by clicking on a button...if you want a starter code i could probably get you something
  4. http://www.phpfreaks.com/phpmanual/page/function.mail.html

    A whole tutorial on mail

    when your form sends to another page just use
    $Email = $_POST['Email']

    Or whatever your form object is called...the variable will be set to the data entered into the form object and you can use it from there
  5. [code]<?php
    session_start();
    header("Cache-control: private");
    ?>
    <?php
    $ip = $_SERVER["REMOTE_ADDR"];
    $songname = $_GET['songname'];
    $songartist = $_GET['songartist'];
    //first, check if the users ip needs to be added to the database.
    function insertuser($id,$ip,$voted){
    include "config.php";
    if (isset($_SESSION['firsttime'])){
    $insertsong = "INSERT INTO users (`id`, `ip`, `voted`) VALUES ('','".$ip."','".$voted."')";
    $insertquery=mysql_query($insertsong, $conn)or die(mysql_error());
    if($insertquery=mysql_query($insertsong)){
    echo "You can request or vote for two more songs";
    }else{
    echo "An error has occurred. An administrator has been notified. thanks";
    }
    }
    }

    //if the user has voted before, once he requestes, increase his voted by 1
    function previoususer($ip){
    include "config.php";
    if (isset($_SESSION['previoususer'])){
    $findhim="SELECT voted FROM users WHERE ip = $ip UPDATE voted SET voted=voted+1";
    mysql_query($findhim,$conn)or die(mysql_error());
    }
    }

    function request($songname,$songartist){
    //get the variables and secure them blah blah blah
    $songname = strtolower($songname);
    $songartist = strtolower($songartist);

    $songname=str_replace(" ","",$songname);
    $songartist=str_replace(" ","",$songartist);

    $songname=str_replace("%20","",$songname);
    $songartist=str_replace("%20","",$songartist);

    $songname=addslashes($songname);
    $songartist=addslashes($songartist);

    //secure it some more! ALRIGHT (h)
    if (!get_magic_quotes_gpc()) {
      foreach ($_REQUEST as $el) {
            $el = mysql_real_escape_string($el);
      }
    }

    //Check if the song already exists
    include "config.php";
    $sql = "SELECT songname AND songartist FROM songs WHERE songname='".$songname."' AND songartist='".$songartist."'";
    $result=mysql_query($sql,$conn)or die(mysql_error());
    if(mysql_num_rows($sql) > 0){
    $query="UPDATE votes FROM songs SET votes=votes+1";
    $gettowork= mysql_query($query,$conn)or die(mysql_error());
    if($gettowork){
    echo "Your request was submitted succesfully";
    }else{
    echo "An error occured, your request was not successful";
    }
    }elseif(mysql_num_rows < 1){
    $songvotes= 0;
    $insertsong = "INSERT INTO songs (`songid`, `songname`, `songartist`, `songvotes`) VALUES ('','".$songname."','".$songartist."','".$songvotes."')";
    $insertquery=mysql_query($insertsong, $conn)or die(mysql_error());
    if($insertquery){
    echo "The song was requested successfully";
    }else{
    echo "There was an error. The song was not requested successfully";
    }
    }

    //begin the actual script
    //determine whether this is hacking attempt/the user is lazy
    if(!empty ($songname) && ($songartist)){
    error_reporting(E_ALL);
    include "config.php";
    request();
    insertuser();
    previoususer();
    mysql_close();
    exit();

    }else{

    echo "A field was left blank";
    exit();
    }
    }

    insertuser('',$ip,'1');
    previoususer($ip);
    ?>[/code]

    Okay try this...this is without the request function something is screwed up in the bottom half of that function try this and if it gives you a white screen no info check your database to see if your vote number or anything was changed...first delete your ip from your database table just see if these two functions work before we move onto request
  6. [code]
    <?
    $ip = $_SERVER["REMOTE_ADDR"];
    $songname = $_GET['songname'];
    $songartist = $_GET['songartist'];
    //first, check if the users ip needs to be added to the database.
    function insertuser($id,$ip,$voted){
    include "config.php";
    if (isset($_SESSION['firsttime'])){
    $insertsong = "INSERT INTO users (`id`, `ip`, `voted`) VALUES ('','".$ip."','".$voted."')";
    $insertquery=mysql_query($insertsong, $conn)or die(mysql_error());
    if($insertquery=mysql_query($insertsong)){
    echo "You can request or vote for two more songs";
    }else{
    echo "An error has occurred. An administrator has been notified. thanks";
    }
    }
    }

    //if the user has voted before, once he requestes, increase his voted by 1
    function previoususer($ip){
    include "config.php";
    if (isset($_SESSION['previoususer'])){
    $findhim="SELECT voted FROM users WHERE ip = $ip UPDATE voted SET voted=voted+1";
    mysql_query($findhim,$conn)or die(mysql_error());
    }
    }

    function request($songname,$songartist){
    //get the variables and secure them blah blah blah
    $songname = strtolower($songname);
    $songartist = strtolower($songartist);

    $songname=str_replace(" ","",$songname);
    $songartist=str_replace(" ","",$songartist);

    $songname=str_replace("%20","",$songname);
    $songartist=str_replace("%20","",$songartist);

    $songname=addslashes($songname);
    $songartist=addslashes($songartist);

    //secure it some more! ALRIGHT (h)
    if (!get_magic_quotes_gpc()) {
      foreach ($_REQUEST as $el) {
            $el = mysql_real_escape_string($el);
      }
    }

    //Check if the song already exists
    include "config.php";
    $sql = "SELECT songname AND songartist FROM songs WHERE songname='".$songname."' AND songartist='".$songartist."'";
    $result=mysql_query($sql,$conn)or die(mysql_error());
    if(mysql_num_rows($sql) > 0){
    $query="UPDATE votes FROM songs SET votes=votes+1";
    $gettowork= mysql_query($query,$conn)or die(mysql_error());
    if($gettowork){
    echo "Your request was submitted succesfully";
    }else{
    echo "An error occured, your request was not successful";
    }
    }elseif(mysql_num_rows < 1){
    $songvotes= 0;
    $insertsong = "INSERT INTO songs (`songid`, `songname`, `songartist`, `songvotes`) VALUES ('','".$songname."','".$songartist."','".$songvotes."')";
    $insertquery=mysql_query($insertsong, $conn)or die(mysql_error());
    if($insertquery){
    echo "The song was requested successfully";
    }else{
    echo "There was an error. The song was not requested successfully";
    }
    }

    //begin the actual script
    //determine whether this is hacking attempt/the user is lazy
    if(!empty ($songname) && ($songartist)){
    session_start();
    error_reporting(E_ALL);
    $ip = $_SERVER["REMOTE_ADDR"];
    include "config.php";
    request();
    insertuser();
    previoususer();
    mysql_close();
    exit();

    }else{

    echo "A field was left blank";
    exit();
    }
    }

    insertuser('',$ip,'1');
    previoususer($ip);
    request($songname,$songartist);
    ?>
    [/code]
    I changed numerous things try that
  7. Well if your sending your form to index2.php which I understand to be the page we were working on, that page isn't using the functions it's creating them.  See when you send that person to the page it compiles all those functions and puts them in standby waiting for you to use them


    For example say you wanted to insert a user using that function

    [code]
    <?php
    function insertuser($id,$ip,$voted) {
    if (isset($_SESSION['firsttime'])){
    $insertsong = "INSERT INTO users (`id`, `ip`, `voted`) VALUES ('','".$ip."','".$voted."')";
    $insertquery=mysql_query($insertsong, $conn)or die(mysql_error());
    if($insertquery=mysql_query($insertsong)){
    echo "You can request or vote for two more songs";
    }else{
    echo "An error has occurred. An administrator has been notified. thanks";
    }
    }
    }

    $ip = $_SERVER["REMOTE_ADDR"];
    $voted=1;

    insertuser('',$ip,$voted);
    ?>[/code]


    Any variables you want inside your function have to be added to the list just like database stuff
  8. Give this a try tell me how it goes

    [code]
    <?
    //first, check if the users ip needs to be added to the database.
    function insertuser(){
    include "config.php";
    $ip = $_SERVER["REMOTE_ADDR"];
    if (isset($_SESSION['firsttime'])){
    $voted=1;
    $insertsong = "INSERT INTO users (`id`, `ip`, `voted`) VALUES ('','".$ip."','".$voted."')";
    $insertquery=mysql_query($insertsong, $conn)or die(mysql_error());
    if($insertquery=mysql_query($insertsong)){
    echo "You can request or vote for two more songs";
    }else{
    echo "An error has occurred. An administrator has been notified. thanks";
    }
    }
    }



    //if the user has voted before, once he requestes, increase his voted by 1
    function previoususer(){
    include "config.php";
    $ip= $_SERVER["REMOTE_ADDR"];
    if (isset($_SESSION['previoususer'])){
    $findhim="SELECT voted FROM users UPDATE voted SET voted=voted+1";
    mysql_query($findhim,$conn)or die(mysql_error());
    }
    }


    function request(){
    //get the variables and secure them blah blah blah
    $songname = $_REQUEST['songname'];
    $songartist = $_REQUEST['songartist'];
    $songname = strtolower($songname);
    $songartist = strtolower($songartist);

    $songname=str_replace(" ","",$songname);
    $songartist=str_replace(" ","",$songartist);

    $songname=str_replace("%20","",$songname);
    $songartist=str_replace("%20","",$songartist);

    $songname=addslashes($songname);
    $songartist=addslashes($songartist);

    //secure it some more! ALRIGHT (h)
    if (!get_magic_quotes_gpc()) {
      foreach ($_REQUEST as $el) {
            $el = mysql_real_escape_string($el);
      }
    }

    //Check if the song already exists
    include "config.php";
    $sql = "SELECT songname AND songartist FROM songs WHERE songname='".$songname."' AND songartist='".$songartist."'";
    $result=mysql_query($sql,$conn)or die(mysql_error());
    if(mysql_num_rows($sql) > 0){
    $query="UPDATE votes FROM songs SET votes=votes+1";
    $gettowork= mysql_query($query,$conn)or die(mysql_error());
    if($gettowork){
    echo "Your request was submitted succesfully";
    }else{
    echo "An error occured, your request was not successful";
    }
    }elseif(mysql_num_rows < 1){
    $songvotes= 0;
    $insertsong = "INSERT INTO songs (`songid`, `songname`, `songartist`, `songvotes`) VALUES ('','".$songname."','".$songartist."','".$songvotes."')";
    $insertquery=mysql_query($insertsong, $conn)or die(mysql_error());
    if($insertquery){
    echo "The song was requested successfully";
    }else{
    echo "There was an error. The song was not requested successfully";
    }
    }

    //begin the actual script
    //determine whether this is hacking attempt/the user is lazy
    if(!empty ($songname) && ($songartist)){
    session_start();
    error_reporting(E_ALL);
    $ip = $_SERVER["REMOTE_ADDR"];
    include "config.php";
    request();
    insertuser();
    previoususer();
    mysql_close();
    exit();

    }else{

    echo "A field was left blank";
    exit();
    }
    ?>
    [/code]

    I organized it a bit to show more of where things start and end you also had an unnecessary closing to a statement which is your white page problem
×
×
  • 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.