SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Nottingham, UK
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validation Check Problem

    PHP Code:
    function insert_vinyl()
            {
                
    $title $_POST['title'];
                
    $artist $_POST['artist_id'];
                
    $release_date $_POST['year']."-".$_POST['month']."-".$_POST['date'];
                
    $genre $_POST['genre_id'];
                
    $price $_POST['price'];
                
    $qty $_POST['qty'];
                
    $info $_POST['comments'];
                
                if(empty(
    $title)) error_message("No Title Entered");
                if(empty(
    $price)) error_message("No Price Entered");
                if(empty(
    $qty)) error_message("No Qty Entered");
                if(empty(
    $info)) error_message("Please Enter some Information about the vinyl");
                if(empty(
    $catno)) error_message("No Catalogue Number Entered");        
                
                
                
    $link_id db_connect();
                
                
    $query "insert into vinyls(cat_no, title, artist_id, release_date, genre_ref, price, stock_level, vinyl_information)
              values( NULL , '
    $title', '$artist', '$release_date' , '$genre', '$price' , '$qty' , '$info')";
                    
                    
    $result mysql_query($query$link_id) or die(mysql_error());        
                if(
    $result)
                {
                    echo 
    'Succesfully Entered';
                }
                
            }
    ?> 

    Im trying to get some validation into my scripts the above seems to do the trick only problem is that after the validation bos appearing and the user clicking the ok button the page goes to the

    'warning page has experied meaning i have to refresh the page and lose the data i had entered.'

    Any idea why this is and how i can change it?

  2. #2
    SitePoint Addict
    Join Date
    May 2004
    Location
    .
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I'm not sure I completely understand the problem. Am I right that you want to have all the information to get back to the form if one of the fields was not completed?

    In that case you should dynamically generate the form page. I suggest you to use Smarty templating engine for that purpose.

    http://smarty.php.net/
    Ilya Devyatovsky
    ThinkHost, Inc.
    Wind/solar powered web hosting - 6 months free!

  3. #3
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get everything except the "after the validation bos appearing" part.

    Chris Shiflett wrote an article about avoiding page expiration a while back.

  4. #4
    SitePoint Addict
    Join Date
    May 2004
    Location
    .
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess there is something outside of the code you have provided that gives you the "expired" error message. I can't help you with the code without seeing the full source files.
    Ilya Devyatovsky
    ThinkHost, Inc.
    Wind/solar powered web hosting - 6 months free!

  5. #5
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Nottingham, UK
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    full code of this script is here. Anything else just ask cheers.


    PHP Code:
    <?php
        
        
    require_once('common_db.php');
        
        function 
    get_vinyl_details($catno)
        {
            if (!
    $catno || $catno=='')
                return 
    false;
            
            
    $link_id db_connect();
            
    $query "select * from vinyls where cat_no='$catno'";
            
    $result = @mysql_query($query$link_id) or die ("There was a problem with this query.");
            if (!
    $result)
                return 
    false;
            
    $result = @mysql_fetch_array($result);
            return 
    $result;
        }
        
        
        
    //functions written with reference from PHP and Mysql development 2nd edition page 522,523.
        
        
    function db_result_to_array($result)    
        {
            
    $res_array = array();
            for (
    $count=0$row = @mysql_fetch_array($result); $count++)  
                
    $res_array[$count] = $row;                
            return 
    $res_array;   
        }
        
        
    //code for get_artist() & get_genre() used from Luke Wellings PHP and Mysql Web Development Second Edition
        
        
    function get_artists()
        {
            
    $link_id db_connect();
            
    $query 'select artist_id from artists';
            
            
    $result = @mysql_query($query$link_id);
            
            if (!
    $result)
                return 
    false;
            
    $num_artists = @mysql_num_rows($result);
            if(
    $num_artists == 0)
                return 
    false;
            
            
    $result db_result_to_array($result);
            return 
    $result;
        }
        
        function 
    get_status()
        {
            
    $link_id db_connect();
            
    $query 'select status_code, status_description from status';
            
            
    $result = @mysql_query($query$link_id);
            
            if (!
    $result)
                return 
    false;
            
    $num_artists = @mysql_num_rows($result);
            if(
    $num_artists == 0)
                return 
    false;
            
            
    $result db_result_to_array($result);
            return 
    $result;
        }
        
        function 
    get_genres()
        {
            
    $link_id db_connect();
            
    $query 'select genre_ref, genre_description from genres';
            
            
    $result = @mysql_query($query$link_id);
            
            if (!
    $result)
                return 
    false;
            
    $num_genres = @mysql_num_rows($result);
            if(
    $num_genres == 0)
                return 
    false;
            
            
    $result db_result_to_array($result);
            return 
    $result;
        }
        
        
        
        
        function 
    addrecord(){
    ?>

    <td valign="top" align="center" width="581" height="600"><form align="center" name="newrecord" method="post" action="stock.php?action=addrecord">
            <table bordercolor="#FFFFFF" border="1" bgcolor="#7b9815">
                <font color="#000000" size="2" face="Courier New, Courier, mono">
                    <tr>
                        <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Title: </font></td>
                        <td><input name="title" type="text" maxlength="40" id="title"></td>
                    </tr>
                    <tr>
                        <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Artist: </font></td>
                        <td><select name="artist_id">
                                <?php
            $artist_array
    =get_artists();
            foreach (
    $artist_array as $thisartist)
            {
                echo 
    '<option value="';
                echo 
    $thisartist['artist_id'];
                echo 
    '"';
                echo 
    '>';
                echo 
    $thisartist['artist_id'];
                echo
    '</option>';
                echo
    "\n";
            }
                                
    ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Release Date: </font></td>
                        <td><select name="date"><?php 
            $nums 
    range(131);
            foreach (
    $nums as $num
            {
                echo 
    '<option value="';
                echo 
    $num;
                echo 
    '"';
                echo 
    '>';
                echo 
    $num;
                echo 
    '</option>';
                echo 
    "\n";
            } 
    ?>
                            </select>
                            <select name="month"><?php 
            $nums 
    range(112);
            foreach (
    $nums as $num
            {
                echo 
    '<option value="';
                echo 
    $num;
                echo 
    '"';
                echo 
    '>';
                echo 
    $num;
                echo 
    '</option>';
                echo 
    "\n";
            } 
    ?>
                            </select>
                            <select name="year"><?php 
            $nums 
    range(19982005);
            foreach (
    $nums as $num
            {
                echo 
    '<option value="';
                echo 
    $num;
                echo 
    '"';
                echo 
    '>';
                echo 
    $num;
                echo 
    '</option>';
                echo 
    "\n";
            } 
    ?>
                            </select></td>
                    </tr>
                    <tr>
                        <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Genre: </font></td>
                        <td><select name="genre_id">
                                <?php
            $genre_array
    =get_genres();
            foreach (
    $genre_array as $thisgenre)
            {
                echo 
    '<option value="';
                echo 
    $thisgenre['genre_ref'];
                echo 
    '"';
                echo 
    '>';
                echo 
    $thisgenre['genre_ref'];
                echo
    '</option>';
                echo
    "\n";
            }
                                
    ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Vinyl Status: </font></td>
                        <td><select name="status_code">
                                <?php
            $status_array
    =get_status();
            foreach (
    $status_array as $thisstatus)
            {
                echo 
    '<option value="';
                echo 
    $thisstatus['status_code'];
                echo 
    '"';
                echo 
    '>';
                echo 
    $thisstatus['status_description'];
                echo
    '</option>';
                echo
    "\n";
            }
                                
    ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Price: </font></td>
                        <td><input name="price" type="text" maxlength="5" id="price"></td>
                    </tr>
                    <tr>
                        <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Qty: </font></td>
                        <td><input name="qty" type="text" maxlength="3" id="qty"></td>
                    </tr>
                    <tr>
                        <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Vinyl Information</font></td><td><textarea name="comments" maxlength="225" cols="60" rows="10"></textarea></td>
                    </tr>
                    <tr>
                        <td align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Image</font></td><td align="left"><input type="file" name="image" size="40"></td>
                    </tr>
                    <tr>
                        <td><input type="submit" value="Submit"></td><td><input type="reset" value="Reset"></td>
                    </tr>
                    <table></form>    
                    
                    <div align="left"></div></td>
            </tr>
        </table></td>
            </tr>
        </table>
        <?
        
    }
            
            
            function 
    checkAdminLogin()
            {
                
                if     (
    $_SESSION['rank'] != '2')
                {
                    
    error_message("Not Authorized to View this Section");
                }    
            }
            
            
            function 
    contact_form()
            {
        
    ?>
        <center>       <table width="779" border="0" cellspacing="2" cellpadding="2" align="center">

    <tr> 
        <td width="30%" height="0"></td>
        <td width="70%"></td>
    </tr>
    <tr>
        <td height="156" valign="top" ><table width="162" border="1" cellspacing="2" cellpadding="2" bgcolor="#7b9815" bordercolor="#d2e982">
                
                <tr> 
                    <td width="200" align="center" valign="middle" bgcolor="#44802c"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">Welcome DJ\'s </div></font></td>
            </tr>
            <tr> 
                <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">p: 0115 9706854</div></font></td>
            </tr>
            <tr> 
                <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">e: enqiures@funkymonkey.co.uk</div></font></td>
            </tr>
            <tr> 
                <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">f: 0115 9706855</div></font></td>
            </tr>
            <tr> 
                <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">18 Main Street, Hockley, Nottingham, NG1 7DD</div></font></td>
            </tr>
            
            <tr> 
                <td width="200" align="center" valign="middle" bgcolor="#44802c"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">Menu</div></font></td>
        </tr>
        <tr> 
            <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="logout.php">Logout</a></div></font></td>
        </tr>
        <tr> 
            <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="register2.php">Sign-up for an Account</a></div></font></td>
        </tr>
        <tr> 
            <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="newreleases.php">Just In</a></div></font></td>
        </tr>
        <tr> 
            <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="barginbins.php">Bargin Bins</a></div></font></td>
        </tr>
    </tr>
            </table></td>
        <td valign="top" align="center"><table width="624" border="0" align="right" cellpadding="0" cellspacing="0">
    <tr> 
        <td valign="top" width="620" height="600"><form align="center" name="contact" method="post" action="contactformsent.php">
                <table bordercolor="#FFFFFF" border="1" bgcolor="#7b9815">
                    <font color="#000000" size="2" face="Courier New, Courier, mono">
                        <tr>
                            <td><div align="left"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">Email address: </div></font></td>
                            <td><div align="left"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif"><input name="email" type="text" maxlength="40" id="email"></div></font></td>
                        </tr>
                        <tr>
                            <td><div align="left"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">Topic: </div></font></td>
                            <td><div align="left"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif"><select name="topics">
                                            <option name="websitefeedback">Website Feedback</option>
                                            <option name="customerfeedback">Customer Feedback</option>
                                            <option name="enquiry">Product Enquiry</option>
                                            <option name="fincace">Finance Enquiry</option>
                                            <option name="return">Returns Enquiry</option>
                                            <option name="music">Music Enquiry</option>
                                            <option name="address">Change of Address</option>
                                            
                                            
                                        </select>
                                    </div></font></td>
                        </tr>
                        <tr>
                            <td><div align="left" valign="top"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">Commets: </div></font></td>
                            <td><div align="left"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif"><textarea name="comments" cols="60" rows="10"></textarea><br/></div></font></td>
                            
                        </tr>
                        <tr>
                            <td><input type="submit" value="Send Message"></td><td><input type="reset" value="Reset"></td>
                        </tr>
                    </table></form>    
                
            </td>
        </tr>
    </table></td>
        </tr>
    </table></center>
        
        <?
            
    }
            
            function 
    display_main_menu(){
                
    ?>
                <center><table width="779" border="0" cellspacing="2" cellpadding="2" >

      <tr> 
        <td width="30%" height="0"></td>
        <td width="70%"></td>
      </tr>
      <tr>
        <td height="156" valign="top"><center><table width="162" border="1" cellspacing="2" cellpadding="2" bgcolor="#7b9815" bordercolor="#d2e982">
            
            <tr> 
                <td width="200" align="center" valign="middle" bgcolor="#44802c"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif"><?php
                
    if     ($_SESSION['rank'] == '1')
                {
                    print 
    "Welcome Back      ".$_SESSION['first_name']." ".$_SESSION['surname']."";
                }else {
                    if (
    $_SESSION['rank'] == '2')
                    {
                        print 
    "Welcome Back ".$_SESSION['first_name']." ".$_SESSION['surname']."";
                    }else
                    print 
    'Welcome DJ\'s'
                }
                
                        
    ?></div></font></td>
            
            
        </tr>
        <tr> 
            <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">p: 0115 9706854</div></font></td>
        </tr>
        <tr> 
            <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">e: enqiures@funkymonkey.co.uk</div></font></td>
        </tr>
        <tr> 
            <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">f: 0115 9706855</div></font></td>
        </tr>
        <tr> 
            <td><div align="left"><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">18 Main Street, Hockley, Nottingham, NG1 7DD</div></font></td>
        </tr>
        
        <tr> 
            <td width="200" align="center" valign="middle" bgcolor="#44802c"><font color="#FFFFFF" size="3" face="Arial, Helvetica, sans-serif">Menu</div></font></td>
    </tr>

    <tr> 
        <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">
                    <?php
                
    if     ($_SESSION['rank'] == '1')
                {
                    print 
    '[<a href="index.php">Home</a>]';
                }else {
                    if (
    $_SESSION['rank'] == '2')
                    {
                        print 
    '[<a href="index.php">Home</a>]';
                    }else
                    print 
    '[<a href="register.php">Sign Up</a>]';
                    
                } 
    ?></div></font></td>
    </tr>
    <tr> 
        <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="newreleases.php">Just In</a>]</div></font></td>
    </tr>
    <tr> 
        <td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="barginbins.php">Bargin Bins</a>]</div></font></td>
    </tr>
            </tr>
    <?php admin_link(); ?>

          </table></center></td>
        <td  height="600" valign="top"><font color="#44802c" size="3" face="Courier New, Courier, mono">
    <?
            
    }
            
            function 
    admin_link(){
                
                if     (
    $_SESSION['rank'] == '2')
                {
                    print 
    '<tr>';
                    print 
    '<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="admin.php">Admin</a>]</div></font></td>';
                    print 
    '</tr>';
                    print 
    '<tr>';
                    print 
    '<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="logout.php">Logout</a>]</div></font></td>';
                    print 
    '</tr>';
                }    else
                {
                    if (
    $_SESSION['rank'] == '1')
                    {
                        print 
    '<tr>';
                        print 
    '<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="show_cart.php">Shopping Basket</a>]</div></font></td>';
                        print 
    '</tr>';
                        print 
    '<tr>';
                        print 
    '<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="cart.php">My Account</a>]</div></font></td>';
                        print 
    '</tr>';
                        print 
    '<tr>';
                        print 
    '<td><div align="left"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="logout.php">Logout</a>]</div></font></td>';
                        print 
    '</tr>';
                    }
                }
            }
            
            function 
    insert_vinyl()
            {
                
    $title $_POST['title'];
                
    $artist $_POST['artist_id'];
                
    $release_date $_POST['year']."-".$_POST['month']."-".$_POST['date'];
                
    $genre $_POST['genre_id'];
                
    $price $_POST['price'];
                
    $qty $_POST['qty'];
                
    $status $_POST['status_code'];
                
    $info $_POST['comments'];
                
                
                
    //if(empty($title)) error_message("No Title Entered");
                //if(empty($price)) error_message("No Price Entered");
                //if(empty($qty)) error_message("No Qty Entered");
                //if(empty($info)) error_message("Please Enter some Information about the vinyl");
                //if(empty($catno)) error_message("No Catalogue Number Entered");        
                
                
                
    $link_id db_connect();
                
                
    $query "insert into vinyls(cat_no, title, artist_id, release_date, genre_ref, price, stock_level, status_code, vinyl_information)
              values( NULL , '
    $title', '$artist', '$release_date' , '$genre', '$price' , '$qty' , '$status', '$info')";
                    
                    
    $result mysql_query($query$link_id);
                
                if(!
    $result) {
                    print 
    "Database error when executing query error was: ";
                    print 
    mysql_error();
                    exit;
                }
                
                if ((isset(
    $_FILES['image']['name']) && is_uploaded_file($_FILES['image']['tmp_name'])))
                {
                    if (!isset(
    $title)) 
                        
    $title mysql_insert_id();
                    
                    
    $type basename($_FILES['image']['type']);
                    
                    switch (
    $type) {
                    case 
    'jpeg':
                    case 
    'pjpeg':    $filename "images/$title.jpg";
                        
    move_uploaded_file($_FILES['image']['tmp_name'], $filename);
                        
    $query "update vinyls set image = '$filename' where title = $title";
                        
    $result mysql_query($query$link_id);
                        break;
                    default:        print 
    'Invalid Picture Format: '.
                        
    $_FILES['image']['type'];
                    }
                    
                }
            }
            
            
            function 
    updatestockform()
            {
                
    $link_id db_connect();
                
                
    $query "select cat_no, title, artist_id, stock_level from vinyls";
                
                
    $result mysql_query($query$link_id) or die(mysql_error());
                
                if(!
    result)
                {
                    echo 
    'No Stock Returned.';
                    exit;
                }else
                
                
    $list ="<center><table border=\"1\" cellpadding=\"2\" bgcolor=\"#7b9815\" bordercolor=\"#d2e982\">";
                
    $list.="<form align=\"center\" name=\"updatestockform\" method=\"post\" action=\"stock.php?action=updatestock\">";
                
    $list.="<tr><th><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">Catalogue Number</div></font></th>";
                
    $list.="<th><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">Title</div></font></th>";
                
    $list.="<th><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">Artist</div></font></th>";
                
    $list.="<th><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">Qty</div></font></th>";
                
    $list.="<th><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">Add</div></font></th></tr></div></font>";
                
                while(
    $row mysql_fetch_array($result))
                {
                    
    $list.= "<tr>";
                    
    $list.= "<td><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">".$row["cat_no"]."</div></font></td>";
                    
    $list.= "<td><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">".$row["title"]."</div></font></td>";
                    
    $list.= "<td><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">".$row["artist_id"]."</div></font></td>";
                    
    $list.= "<td><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">".$row["stock_level"]."</div></font></td>";
                    
    $list.= "<td width=\"10\"><div align=\"left\"><font color=\"#FFFFFF\" size=\"2\" face=\"Arial, Helvetica, sans-serif\"><input name=\"qty\" type= \"text\" maxlength=\"3\" id=\"qty\"></div></font></td>";
                    
    $list.= "<td><input name=\"qtyselected\" type=\"radio\"></td>";
                    
    $list.=    "<td><input type=\"submit\" value=\"Update\"></td>";
                    
                    
                }
                
    $list.= "</table></center>";
                
                echo(
    $list);
                
            }
            
            function 
    updatestock()
            {
                
    $cat_no $_POST['cat_no'];
                
    $title $_POST['title'];
                
    $stock_level $_POST['stock_level'];
                
    $qty $_POST['qty'];
                
    $new_stock_level $_POST['qty'] + $_POST['stock_level'];
                
                
                
    $link_id db_connect();
                
                
    $query "update vinyls 
                            set stock_level = '
    $new_stock_level'
                            where cat_no = '
    $cat_no'";
                    
                    
    $result mysql_query($query$link_id) or die(mysql_error());    
                
                if(
    $result)
                {
                    echo 
    'Succesfully Entered';
                }
                
                
    updatestockform();
            }
            
            
            function 
    add_artist(){
    ?>

    <td valign="top" align="center" width="581" height="600"><form align="center" name="newrecord" method="post" action="stock.php?action=insertartist">
    <table bordercolor="#FFFFFF" border="1" bgcolor="#7b9815">
        <font color="#000000" size="2" face="Courier New, Courier, mono">
            <tr>
                <td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Artist Name</font></td>
                <td><input name="artist_id" type="text" maxlength="40" id="artist_id"></td>
            </tr><tr>
                <td><input type="submit" value="Submit"></td><td><input type="reset" value="Reset"></td>
            </tr>
            <table></form>    
            
            <div align="left"></div></td>
    </tr>
        </table></td>
            </tr>
        </table>
    <?
            
    }
            
            function 
    insert_artist()
            {
                
                
                
                
    $artist $_POST['artist_id'];
                
                if(empty(
    $artist)) error_message("No Artist Entered");
                
                
                
    $link_id db_connect();
                
                
    $query "insert into artists(artist_id) values( '$artist')";
                
                
    $result mysql_query($query$link_id) or die(mysql_error());        
                if(
    $result)
                {
                    echo 
    'Succesfully Entered';
                }
                
                
            }
            
            
            function 
    display_admin_menu(){
                
    ?>
            <center><table width="362" border="1" cellspacing="2" cellpadding="2" bgcolor="#7b9815" bordercolor="#d2e982">
            <tr> 
            <td><div align="center"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Welcome <?php echo $_SESSION['first_name'] ." ".$_SESSION['surname']." " ?> to Admin</div></font></td>
        </tr>
            <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="stock.php">Stock Section</a>]</div></font></td>
        </tr>
        <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="orders.php">Orders Section</a>]</div></font></td>
        </tr>
        <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="newsboard.php">Newsboard Section</a>]</div></font></td>
        </tr>
        <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="orders.php">Fourms Section</a>]</div></font></td>
        </tr>
        <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="orders.php">Emails Section</a>]</div></font></td>
        </tr>
        
        <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="orders.php">Customers Section</a>]</div></font></td>
        </tr>
    <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="orders.php">Suppliers Section</a>]</div></font></td>
        </tr>
    <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="orders.php">Postage Section</a>]</div></font></td>
        </tr>
    <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="orders.php">Help</a>]</div></font></td>
        </tr>
    <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="orders.php">Contact Webmaster</a>]</div></font></td>
        </tr>
            </tr>
          </table></center></td>
        <td  height="600" valign="top"><font color="#44802c" size="3" face="Courier New, Courier, mono">
    <?
            
    }
            
            
            function 
    display_newsboard_menu(){
                
    ?>
            <center><table width="362" border="1" cellspacing="2" cellpadding="2" bgcolor="#7b9815" bordercolor="#d2e982">
            
            <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="news.php">Create New Article</a>]</div></font></td>
        </tr>
        <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="articles.php">View Articles</a>]</div></font></td>
        </tr>
        <tr> 
            <td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="newsboard.php">Adminstration Menu</a>]</div></font></td>
        </tr>
            <?php checkAdminStatus();?>
        
          </table></center></td>
        <td  height="600" valign="top"><font color="#44802c" size="3" face="Courier New, Courier, mono">
    <?
            
    }
            
            
            function 
    checkAdminStatus()
            {
                
                if     (
    $_SESSION['customer_id'] == '123567')
                {
                    print 
    '<tr>';
                    print 
    '<td><div align="center"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">[<a href="publish.php">Publish</a>]</div></font></td>';
                    print 
    '</tr>';
                }    
            }
            
            
            
            
            
            
            
            
            
            
            
        
    ?>

  6. #6
    SitePoint Addict
    Join Date
    May 2004
    Location
    .
    Posts
    227
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for the delay responding. I couldn't reproduce the error and find the error within the code provided.

    If you used Smarty, the code would be much more readable letting you find the problem easier.
    Ilya Devyatovsky
    ThinkHost, Inc.
    Wind/solar powered web hosting - 6 months free!

  7. #7
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Brooklyn, NY
    Posts
    359
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    Chris Shiflett wrote an article about avoiding page expiration a while back.
    I'm not sure if this helps answer the question, but this article is available for free:

    http://shiflett.org/articles/guru-speak-nov2004

    I hope someone finds it helpful. :-)
    Chris Shiflett
    http://shiflett.org/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •