Jump to content

I need help with organizing this code so the pages load in the order they should


successmatters

Recommended Posts

I have an index page that I can not for the life of me get it to load in the order I would like it to load in.
The code is below, if you can help me it will be greatly appreciated. I will let you know what order I would like it in once someonce respons to let me know they can help me.

Thanks


<form action="index.php" method="post" enctype="text/html">
{if $smarty.request.send_que ne "" and $smarty.session.id eq ""}
<br><h3></h3>
                <table width=300 cellpadding=5 border=0>
                <tr valign=top><td>
                        <table width=300 cellpadding=5 cellspacing=2 class="tablerow">
                        <tr align=center class="tabletitle"><td colspan=2>User Login</td></tr>
                        <tr>
                                <td align=right width=100 class="tablerow">User Name/Email</td>
                                <td><input type="text" name="username" value={$smarty.request.username}></td>
                        </tr>
                        <tr>
                                <td align=right class="tablerow">Password</td>
                                <td><input type="password" name="password" value={$smarty.request.password}></td>
                        </tr>
                        <tr>
                                <td colspan=2 align="center"><a href="pass_recover.php">Forgotten Password?</a></td>
                        </tr>
                        </table>
                </td><td>
                        <table width=300 border=0 cellpadding=5 cellspacig=5 class="tablerow">
                        <tr class="tabletitle" align=center>
                                <td colspan=2>New User Registration</td>
                        </tr>
                        <tr>
                                <td align=right width=100 class="tablerow">User Name</td>
                                <td><input name="rusername" type="text" maxlength=40 value={$smarty.request.rusername}></td>
                        </tr>
                        <tr>
                                <td align=right class="tablerow">Password </td>
                                <td><input name="rpassword" type="password" maxlength=40 ></td>
                        </tr>
                        <tr height=40>
                                <td align=right class="tablerow">Email Address </td>
                                <td><input name="email" type="text" maxlength=100 value={$smarty.request.email}></td>
                        </tr>
                        </table>
                </td></tr>
                </table>
                <h3>Question Details</h3>
{else}
        <br>
        <h3>Ask your Question</h3><b>We Help</b><br>
            Enter details about your question and press the button bellow. All fields are required.
        <br><br>
{/if}
       
                {include file=err.tpl}
                <table width=500 border=0 cellpadding=5 cellspacing=5 class="table">
                <tr class="tabletitle">
                        <td>Your Question</td>
                </tr>
                <tr>
                        <td>
                                <textarea name="que_subject" rows=3 cols=75>{$que_subject}</textarea>
                                <br><br>
                        </td>
                </tr>
{if $smarty.request.que_subject ne ""}
                <tr class="tabletitle">
                        <td>Question Details</td>
                </tr>
                <tr>
                        <td>
                                <textarea name="que_details" rows=8 cols=75>{$que_details}</textarea>
                                <br><br>
                        </td>
                </tr>
                <tr class="tabletitle">
                        <td>Send to</td>
                </tr>
                <tr>
                        <td>
                                <select name="que_cat">
                                        {$cat_ops}
                                </select>
                                <br><br>
                        </td>
                </tr>
                <tr class="tabletitle">
                        <td>Make Your Offer</td>
                </tr>
                <tr>
                        <td>$
                <input type="text" name="que_offer" value={$smarty.request.que_offer}>
                                <br>
                        </td>
                </tr>
{else}
        <input type="hidden" name="que_cat" value="-1">
{/if}
                </table>
                <br>
                <input name="send_que" type="submit" value="Ask >>">
                </form>
               
{if $smarty.request.que_details eq ""}
        {if $d_que_id ne ""}
        <br>
        <table cellpadding=5 cellspacing=1 align="center">
        <tr><td align=center class="b-l"><b>New Open Questions</b></td></tr>
        {section name=i loop=$d_que_id}
                {if $d_private[i] eq ""}
                <tr><td>
                        <a href="forum_answer.php?que_id={$d_que_id[i]}"><font face="Arial Narrowj, Arial, Verdana" size="3">{$d_que_details[i]|truncate:"70"}</font></a><br>
                        <font size=-2>{$d_user_name[i]} offered ${$d_offer[i]} for this question.</font>
                </td></tr>
                {/if}
        {/section}
        </table>
        <br>
        {/if}
{/if}

Link to comment
Share on other sites

Hi,
It's a php script using smarty templates here is the php code that goes with the tpl file.
<?php
        include("include/config.php");
        include("include/function.php");

/*        if(strpos($_POST['que_details'], ".")!=0)
                $que_subject = substr($_POST['que_details'], 0, strpos($_POST['que_details'], ".")+1);
        else
                $que_subject = $_POST['que_details'];
        if(strpos($que_subject, "?")!=0)
                $que_subject = substr($que_subject, 0, strpos($que_subject, "?")+1);
*/

          if($_POST['que_subject']=="")
                $que_subject = $_GET['que_subject'];
          else
                $que_subject = $_POST['que_subject'];
          if($_POST['que_details']=="")
                $que_details = $_GET['que_details'];
          else
                  $que_details = $_POST['que_details'];
          if($_POST['que_cat']=="")
                $que_cat = $_GET['que_cat'];
          else
                $que_cat = $_POST['que_cat'];
          if($_POST['que_offer']=="")
                $que_offer = $_GET['que_offer'];
          else
                $que_offer = $_POST['que_offer'];

        if($_POST['send_que'] or $que_details)
        {
//                if($que_subject==null)
//                        $err = "Enter Subject of your question.";
                if($password)
                        header("Location: login.php?login=Login&username=$username&password=$password&que_subject=".stripslashes($que_subject)."&que_details=".stripslashes($que_details)."&que_cat=$que_cat&que_offer=$que_offer&send_que=$send_que");
                elseif($rusername)
                        header("Location: register.php?register=create&username=$rusername&password=$rpassword&email=$email&que_subject=".stripslashes($que_subject)."&que_details=".stripslashes($que_details)."&que_cat=$que_cat&que_offer=$que_offer");

                if($que_subject==null)
                        $err = "Enter your question please.";
                elseif($que_details==null)
                        $err = "Enter details about your question.";
                elseif($que_cat<0)
                        $err = "";
                elseif($que_cat==0)
                        $err = "Select a subcategory, not a top-level category.";
                elseif($que_offer<$config['min_que_value'])
                        $err = "Enter minimum $$config[min_que_value] to make offer against your question.";
                elseif(is_float($que_offer+0))
                        $err = "Enter integer value to make offer against your question.";
                elseif($_SESSION['id']=="")
                {
                        $login_form = true;
                }
                elseif($confirm == "") {
                        $rs = $conn->execute("select * from category where cat_id=$que_cat");
                        STemplate::assign('que_subject', stripslashes($que_subject));
                        STemplate::assign('que_details', stripslashes($que_details));
                        STemplate::assign("que_cat_title", $rs->fields['cat_title']);
                        STemplate::display("header.tpl");
                        STemplate::display("confirm.tpl");
                        STemplate::display("footer.tpl");
                        exit;
                }
                elseif($confirm!="false")
                {
                        $rs_cat = $conn->execute("select cat_type_id from category where cat_id=$que_cat");
                        $sql = "INSERT INTO `question` ( `que_id` , `userid` , `que_subject` , `que_details` , `cat_id` , `cat_type_id`, `offer_id` , `time_asked` )
                                        VALUES (
                                        '', '$_SESSION[id]', '".htmlspecialchars($que_subject)."', '".htmlspecialchars($que_details)."', '$que_cat', '".$rs_cat->fields['cat_type_id']."', '$que_offer', '".date("Y-m-d H:i:s")."'
                                        )";
                        $conn->execute($sql);
                        $conn->execute("insert offer set offer_id='$que_offer', offer_value='$que_offer'");
                        $rs_p = $conn->execute("select max(posts) as posts_count from expert where userid=$_SESSION[id]");
                       

                        $posts = $rs_p->fields['posts_count'] + 1;
                        $conn->execute("Update expert set
                                        posts=$posts
                                        where userid=$_SESSION[id]
                                ");
                               

                        /* Send email to subscribed expert */
                        $keywords = implode(array_unique(explode(" ", $_POST['que_subject'])), "%' or keyword like '%");
                        $rs = $conn->execute("select distinct * from subscribe where cat_id like '%,$que_cat,%' or keyword like '%$keywords%'");

                        while(!$rs->EOF)
                        {
                                $s_userid[] = $rs->fields['userid'];
                                $rs->movenext();
                        }
                        $rs_q = $conn->execute("select que_id from question where que_subject='$que_subject'");
                        $rs_o = $conn->execute("select offer_value from offer where offer_id=$que_offer");
                        $rs_c = $conn->execute("select cat_title from category where cat_id = $que_cat");

                        for($i=0; $i<count($s_userid); $i++)
                        {
                                $rs_u = $conn->execute("select username, email from expert where userid=$s_userid[$i]");

                                STemplate::assign('user_id', $_SESSION['id']);
                                STemplate::assign('expert_name', $rs_u->fields['username']);
                                STemplate::assign('cat_title', $rs_c->fields['cat_title']);
                                STemplate::assign('que_id', $rs_q->fields['que_id']);
                                STemplate::assign('que_subject', stripslashes($que_subject));
                                STemplate::assign('que_details', stripslashes($que_details));
                                STemplate::assign('offer_value', $rs_o->fields['offer_value']);
                                STemplate::assign('time_asked', date("Y-m-d H:i:s"));
                                STemplate::assign('posted_by', $_SESSION['username']);
                                $to = $rs_u->fields['email'];
                                $name = $config['admin_name'];
                                $from = $config['admin_email'];
                                $subj = $config['site_name']." - New ".$rs_c->fields['cat_title']." Question: $que_subject";
                                $body = STemplate::fetch("mail/notify_new_question.tpl");
                                mailing($to,$name,$from,$subj,$body);
                        }

//                        header("Location: pay_deposit.php?que_id=".$rs_q->fields['que_id']);
                          header("Location: search.php?id=$_SESSION[id]");
                }

        }
        STemplate::assign('que_subject',stripslashes($que_subject));
        STemplate::assign('que_details',stripslashes($que_details));
        STemplate::assign('que_cat',$que_cat);
        STemplate::assign('que_offer',$que_offer);
       
       
        $cat_type[] = "---";
        $offer[] = "---";
/*
        $rs = $conn->execute("select * from category order by cat_title");
        while(!$rs->EOF)
        {
                $cat_type[ $rs->fields['cat_id'] ] = $rs->fields['cat_title']." Specialists";
                $rs->movenext();
        }

        STemplate::assign("cat_type", $cat_type);
*/
       
        $cat_ops.="<option value='0' $sel>---</option>\n";
        $rs = $conn->execute("select * from category_type order by cat_type");

        while(!$rs->EOF)
        {
                $cat_id = "0";
                $cat_type = $rs->fields['cat_type'];
                $cat_ops.="<option value='$cat_id'>$cat_type</option>\n";
                $rs_cat = $conn->execute("select * from category where cat_type_id=".$rs->fields['cat_type_id']." order by cat_title");
                while(!$rs_cat->EOF)
                {
                        $cat_id = $rs_cat->fields['cat_id'];
                        $cat_type = " &nbsp;-".$rs_cat->fields['cat_title']." Specialists";
                        if($_POST['que_cat']==$rs_cat->fields['cat_id']) $sel="Selected"; else $sel="";
                                $cat_ops.="<option value='$cat_id' $sel>$cat_type</option>\n";
                        $rs_cat->movenext();
                }
                $rs->movenext();
        }
                STemplate::assign("cat_ops", $cat_ops);
               

        $rs = $conn->execute("select * from offer");
        while(!$rs->EOF)
        {
                $offer[ $rs->fields['offer_id'] ] = $rs->fields['offer_value'];
                $rs->movenext();
        }

        STemplate::assign("offer", $offer);
       
       
        /* Display New Question */
        if($config['show_recent_que'] == "yes")
        {
                $today = date('d');
                $sql = "select * from question where que_status='Open' order by que_id desc limit $config[recent_que_limit]";
                $rs = $conn->execute($sql);

                while(!$rs->EOF)
                {
                        $rs_u = $conn->execute("select username from expert where userid=".$rs->fields['userid']);

                        $d_que_id[] = $rs->fields['que_id'];
                        $d_que_details[] = $rs->fields['que_details'];
                        $d_offer[] = $rs->fields['offer_id'];
                        $d_user_name[] = $rs_u->fields['username'];
                        $d_private[] = $rs->fields['private'];

                        $rs->movenext();
                }

                STemplate::assign('d_que_id', $d_que_id);
                STemplate::assign('d_que_details', $d_que_details);
                STemplate::assign('d_offer', $d_offer);
                STemplate::assign('d_user_name', $d_user_name);
                STemplate::assign('d_private', $d_private);
        }

        STemplate::assign('send_que',$_REQUEST[send_que]);
        STemplate::assign('err',$err);
        STemplate::display("header.tpl");
        STemplate::display("index.tpl");
        STemplate::display("footer.tpl");
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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