Passing Variables Along in a Function

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-05-04T01:17:49Z Indexed on 2010/05/04 2:18 UTC
Read the original article Hit count: 282

Filed under:

Hello,

In the function show_commentbox() below, I would like to pass along the variables $_SESSION['loginid'], $submissionid, $submission, $url, $submittor, $submissiondate, $countcomments, $dispurl. With the setup below, it's not working. How could I change it to make show_commentbox() pass the variables along?

Thanks in advance,

John

index.php:

<?php 

$submission = $_GET['submission'];

 require_once "header.php"; 

 include "login.php";

 include "comments.php";

 include "commentformonoff.php"; 

?>

In header.php:

require_once ("function.inc.php");

In comments.php:

$uid = $_SESSION['loginid'];
$submissiondate = mysql_real_escape_string($_GET['submissiondate']);
$submittor = mysql_real_escape_string($_GET['submittor']);
$countcomments = mysql_real_escape_string($_GET['countcomments']);
$dispurl = mysql_real_escape_string($_GET['dispurl']);
$url = mysql_real_escape_string($_GET['url']);
$submission = mysql_real_escape_string($_GET['submission']);
$submissionid = mysql_real_escape_string($_GET['submissionid']);

commentformonoff.php:

<?php
if (!isLoggedIn())
{

    if (isset($_POST['cmdlogin']))
    {

        if (checkLogin($_POST['username'], $_POST['password']))
        {
            show_commentbox();
        } else
        {
            echo "Login to comment";

        }
    } else
    {

        echo "Login to comment";
    }

} else
{

    show_commentbox();
}
?>

In display.functions.inc.php:

function show_commentbox()
{
echo '<form  action="http://www...com/sandbox/comments/comments2.php" method="post"> 
    <input type="hidden" value="'.$_SESSION['loginid'].'" name="uid">
    <input type="hidden" value="'.$submissionid.'" name="submissionid">  
    <input type="hidden" value="'.$submission.'" name="submission">
    <input type="hidden" value="'.$url.'" name="url">
    <input type="hidden" value="'.$submittor.'" name="submittor">
    <input type="hidden" value="'.$submissiondate.'" name="submissiondate">
    <input type="hidden" value="'.$countcomments.'" name="countcomments">
    <input type="hidden" value="'.$dispurl.'" name="dispurl">



    <label class="addacomment" for="title">Add a comment:</label>

    <textarea class="commentsubfield" name="comment" type="comment" id="comment" maxlength="1000"></textarea>  

    <div class="commentsubbutton"><input name="submit" type="submit" value="Submit"></div> 
</form>
'; 
}

© Stack Overflow or respective owner

Related posts about php