Jump to content

melting_dog

Members
  • Posts

    118
  • Joined

  • Last visited

    Never

Posts posted by melting_dog

  1. Thanks guys.

     

    i fixed the if statement and using an alert box narrowed the problem down to the get: although the correct variable content is shown in the URL it is not reaching the page: $_GET['comDiscussNo']; has nothing in it (even after changing it like robert suggested).

     

    Anyone got any other ideas? Thanks

     

     

    ...but this is also strange because even if $_GET['comDiscussNo']; has nothing in it the if statement:

     

    $discussIDtrans = $_GET['comDiscussNo'];

    $discussIDpost =(int)$_POST['discussID'];

     

    if ($discussIDtrans == null) {

    $discussID = $discussIDpost;

    }

     

    else {

    $discussID = $discussIDtrans;

    }

     

    should just pass it on to the else statement, making $discussID equal to the POST

     

    weird...

     

  2. Thanks guys.

     

    i fixed the if statement and using an alert box narrowed the problem down to the get: although the correct variable content is shown in the URL it is not reaching the page: $_GET['comDiscussNo']; has nothing in it (even after changing it like robert suggested).

     

    Anyone got any other ideas? Thanks

  3. Hi all,

     

    I have a page that runs a query where users can send info via either a form (post) or from redirecting from another page (get).

     

    The get function uses:

    header("location:forumsDiscussion.php?$comDiscussNo");

    to send content of the $comDiscussNo variable and appears to work fine: i can see the variable content in the URL.

     

    but when i put these into if statements it doesnt run.

    Heres the code:

     

    <?php

     

    $discussIDtrans = $_GET['$comDiscussNo'];

     

    if ($discussIDtrans = null) {

    $discussID=(int)$_POST['discussID'];

    }

     

    else {

    $discussID = $discussIDtrans;

    }

     

    $sql = "SELECT * FROM discussion WHERE discussID ='$discussID'";

     

    ******ETC ETC ETC*******

     

    Anyone have any ideas why this isnt working?

     

    Cheers

  4. Is there anyway to make this work without converting the JavaScript variable to php?

    (a javascript variable inside a value tag inside a form tag within php):

     

    <script type="text/javascript">

    var curdate = new Date();

    </script>

     

    <?php

    echo '<table>';

    echo '<form name="form1" method="post" action="forumsNewCommentProcess.php">';

     

    echo '<tr>';

    echo '<td class="headerCol">Date</td>';

    echo '<td><input name="comDate" type="text" value="' + curdate + '" size="80" maxlength="150" /></td>';

    echo '</tr>';

     

    echo '</form>';

    echo '</table>';

     

    Any help would be appreciated!

     

    Cheers :)

  5. Hi,

     

    I have an include function that has all my header tags (<head>, html document type, css link, <html>, etc)

     

    But I want to redirect my to another page later on in my code (in an 'if' statement).

     

    I realise that you cannot use header(location:####) within the html tags. Is there another way to redirect?

     

    Cheers.

  6. Hi all,

    Im constructing a JQuery drop down menu system and have come accross two problems. The first is that when the page first loads the submenu is visable (but works properly when i roll over it) and the 2nd is that I cannot seem to repeat the process for the the other items in the navigation menu - it only works for the first one.

     

    Here is my code:

    <script src="jquery-1.4.2.min.js" type="text/javascript"></script>

     

    <script type="text/javascript">

    $(document).ready(function(){

     

    $(function() {

        $('#nav li').hover(function() {

              $('div.subMenu', this).show(400);

          }, function() {

              $('div.subMenu', this).hide(400);

          });

    });  

     

    $(function() {

        $('#nav li').hover(function() {

              $('div.subMenu2', this).show(400);

          }, function() {

              $('div.subMenu2', this).hide(400);

          });

    });

     

    });

    </script> 

     

     

     

    <div id="nav">

    <ul>

        <li><a href="index.php"><img src="images/homeBtn.gif" alt="Home"/></a>

            <div class="subMenu">Return to the home page.</div></li>

          <li><a href="about.php"><img src="images/aboutBtn.gif" alt="About"/></a></li>

            <div class="subMenu2">Learn more about the SDM&A.</div></li>

    </div>

     

    Any help would be greatly appreciated!

  7. Hi.

     

    I need to use the total count of items from a table in an equation in javascript.

     

    This is as close as I have gotten:

     

    $sql =  "SELECT COUNT(mailingID) FROM mailinglist";

    $result = mysql_query($sql);

    var sum=  "<?= $result ?>";

     

    var sum returns the correct number but preceded by Resource id# (i.e. Resource id #5) and I cannot use this for equations. Any one got any ideas on how to just get the number?

     

    Cheers

     

  8. Firstly, if you're going to use any $_SESSION data, you need to have session_start(); at the beginning of the script. Also, session_register() is deprecated. and should be changed to use the correct syntax (see below). And I can't think of any good reason to store a password in a $_SESSION var. Lastly, after a header() redirect, you should always follow it with exit(); to prevent the script form executing any further.

    $_SESSION['name'] = $name;
    

     

    Thanks Robert and Pikachu. I have updated the session_register to $_SESSION.

     

    It seems as if the session_start wasw the problem: i had it on a thrid page that redirected from loginProcess.php but have changed it to where robert suggested.

     

    So alls fine now but i might have to do some more testing...

     

    Cheers

  9. Hi all.

     

    Im probably missing something here so forgive me if this is a noob question. I have created a login page for a site I am building at home with xampp. For the last week its been fine but just today when I try to use the login it redirects me to main.php - theres no such page in my folder structure.

     

    my login looks something like this:

     

    Login in page:

     

    <form name="form1" method="post" action="loginProcess.php">

    <input name="name" type="text" value="Name" size="40" maxlength="100" />

    <input name="password" type="password" value="password" size="40" maxlength="100" />

    <label><input type="submit" name="Submit" id="Submit" value="Submit" /></label>

    </form>

     

    loginProcess page (which doesnt actually get reached):

     

    $name=$_POST['name'];

    $password=$_POST['password'];

     

    $name = stripslashes($name);

    $password = stripslashes($password);

    $name = mysql_real_escape_string($name);

    $password = mysql_real_escape_string($password);

     

    $sql="SELECT * FROM $tbl_name WHERE firstName='$name' and password='$password'";

    $result=mysql_query($sql);

    $count=mysql_num_rows($result);

    if($count==1){

    session_register("name");

    session_register("password");

    header("location:loginSuccess.php");

    }

    else {

    $wrong = '<h3 style = "text-align: center;">Sorry! Wrong Username or Password</h3>';

    }

    ob_end_flush();

    ?>

     

    Oddly enough, when I put in an incorrect name or password it does redirect to the right page. - Just wierd

     

    anyone know why this is happening?

  10. I'm trying to implement a code that will simply delete a row via a pre-entering an ID. Pretty simple, but I seem to be missing something so some other opinions would be appreciated.

     

    The postID is sent from a form. So:

     

    $postID=$_POST['postID'];

    $postID = stripslashes($postID);

    $postID = mysql_real_escape_string($postID);

     

    $sql="SELECT * FROM $tbl_name WHERE postID='$postID'";

    $result=mysql_query($sql);

    $count=mysql_num_rows($result);

     

    if($count==1){

    $sql="DELETE FROM $tbl_name WHERE postID='$postID' LIMIT 1";

    $result = '<p>Successfully Removed</p><a href="index.php">Back to Home Page</a>';

    }

     

    else {

    $result = '<h3 style = "text-align: center;">Sorry! No Posts with that ID were found.</h3><a href="removePost.php">Try Again?</a>';

    }

    ob_end_flush();

    ?>

     

    Yeah so like i said probably something simple but any help would be greatly appreciated

     

    Cheers

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