SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist AlexC's Avatar
    Join Date
    Oct 2000
    Location
    Sheffield, UK
    Posts
    437
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I have set up my main script, and am adding the content management part...but am having a problem

    if $addpage=1 then it displays a form

    the problem is, when you submit...it dosen't write to the db...nothing happens

    if anyone could help, PLEASE DO!

    Code:
      <?php 
    if (isset($addpage)):
    ?> 
            <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
              <P>Type the page text here<BR>
                <TEXTAREA NAME="pagetext" ROWS=20 COLS=50 WRAP></TEXTAREA>
                <BR>
                Please type in the page reference, this is the 'tag' on the end, i.e 
                misc.php?page=reference:<br>
                <input type="text" name="page">
                <br>
                Please type your name:<br>
                <input type="text" name="name">
                <br>
                <INPUT TYPE=SUBMIT NAME="submitpage" VALUE="SUBMIT">
            </FORM>
            <?php
    else:
    
    mysql_connect("localhost", "root", "noway");
    mysql_select_db("misc");
    mysql_query("INSERT INTO pages SET page='$page', Author='$name', DateAdded='20001020', pagetext='$pagetext'");
    
    
    endif;
    
    ?>
    Thanx for james helping me get this far

    SITEPOINT RULES!

    Alex

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I like to do my query above the form output like so:

    <?php
    if ($submitpage == "SUBMIT") {
    mysql_connect("localhost", "root", "noway");
    mysql_select_db("misc");
    mysql_query("INSERT INTO pages SET page='$page', Author='$name', DateAdded='20001020', pagetext='$pagetext'");
    }
    if (isset($addpage)) {
    ?>
    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
    <P>Type the page text here<BR>
    <TEXTAREA NAME="pagetext" ROWS=20 COLS=50 WRAP></TEXTAREA>
    <BR>
    Please type in the page reference, this is the 'tag' on the end, i.e
    misc.php?page=referencebr>
    <input type="text" name="page">
    <br>
    Please type your namebr>
    <input type="text" name="name">
    <br>
    <INPUT TYPE=SUBMIT NAME="submitpage" VALUE="SUBMIT">
    </FORM>
    <?php
    }

    ?>

    <Edited by freddydoesphp on 01-01-2001 at 01:13 PM>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •