WordPress.org

Ready to get started?Download WordPress

Forums

Custom form on pages leads to 404? (2 posts)

  1. fxchain
    Member
    Posted 8 years ago #

    I am trying to add a form that updates a MySQL DB to a page, but the submit leads to the WP 404 page. The form action goes to a page that has 'alumni' as the parent page and is named 'update' and has its own template (/alumni/update/).

    Check out the code:

    --------------------------------------------------------

    <?php
    /*
    Template Name: Edit Alumni
    */
    ?>

    <?php
    $link = mysql_connect("localhost", "user", "pass") or die("Could not connect : " . mysql_error());
    mysql_select_db("DBname") or die("Could not select database");

    //Edit a student ?id=12
    $id = $_GET['id'];
    $gofetch = mysql_query ("SELECT * FROM alumni WHERE id=$id");
    $values = mysql_fetch_array($gofetch, MYSQL_ASSOC);
    //echo "<div class=\"astudent\">$values[last], $values[first] graduated in $values[speciality] $values[year]</div><div class=\"syear\">$values[picture]</div>";
    ?>

    <?php get_header(); ?>

    <div id="content" class="alumnicontent">
    <div class="post">
    <h1>Edit Alumni</h1>

    <form id="ealumni" action="http://beta.thedomainname.org/alumni/update/" method="post">
    <div class="group">
    <label for="first">First Name:</label>
    <input name="first" id="first" class="input" type="text" size="20" <?php if(isset($values[first])) echo "value=\"".$values[first]."\"";?> /> <span class="required">*</span>
    <label for="last">Last Name:</label>
    <input name="last" id="last" type="text" class="input" size="20" <?php if(isset($values[last])) echo "value=\"".$values[last]."\"";?> /> <span class="required">*</span>
    </div>
    <br class="clearboth" />
    <div class="group">
    <label for="degree">Degree:</label>
    <input name="degree" id="degree" class="input" type="text" size="20" <?php if(isset($values[speciality])) echo "value=\"".$values[speciality]."\"";?> />   
    <label for="year">Year:</label>
    <input name="year" id="year" class="input" type="text" size="20" <?php if(isset($values[year])) echo "value=\"".$values[year]."\"";?> />
    </div>
    <br class="clearboth" />
    <label for="image">Image:</label>  
    <input type="file" name="image" size="25" maxlength="255" <?php if(isset($values[picture])) echo "value=\"".$values[picture]."\"";?> />

    <input type="hidden" name="id" value="<?=$id?>" />
    <input type="submit" name="Submit" value="Submit" class="submit" />
    </form>

    <?php //get_editAlumniForm(); ?>

    <br class="clearboth" />
    Go Back
    <?php
    mysql_close($link);
    ?>
    <br class="clearboth" />
    </div>
    </div>
    <?php get_footer(); ?>

    --------------------------------------------------------

  2. fxchain
    Member
    Posted 8 years ago #

    .htaccess is CHMOD 666.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags