Help with a php Form

Discussion in 'Web Design and Development' started by 3rd Doctor, Mar 25, 2010.

  1. 3rd Doctor macrumors member

    Joined:
    Dec 4, 2009
    #1
    I have a form which is used to edit records in a mysql database via php. The fields are successfully pulled from the database and inserted in the form, i edit the fields as required, however when i press submit, nothing happens, i have a feeling there is a silly syntax error in my form code as no php errors are displayed:

    Code:
    	echo '<form action="edit_record.php" method="post">
    	
    <p>Created By: <input type="text" disabled="disabled" name="created_by" size="15" maxlength="15" value="' . $row[0] . '" /></p>
    <p>Start Time: <input type="text" name="start_time" size="30" maxlength="20" value="' . $row[1] . '" /></p>
    <p>End Time: <input type="text" name="end_time" size="30" maxlength="20" value="' . $row[2] . '"  /> </p>
    <p>Description:<br /> <textarea rows="6" cols="40" name="description">' . $row[3] . '</textarea> </p>
    <p>Status: <select name="status" id="status" Value="' . $row[4] . '">
    	<option>Open</option>
    	<option>Work in Progress</option>
    	<option>Cancelled</option>
    	<option>Closed</option>
    </select>
    </p>
    <p>Assigned to: <input type="text" disabled="disabled" name="assigned_to" size="15" maxlength="15" value="' . $row[5] . '" /></p>
    
    <p><input type="submit" name="submit" value="Submit" /></p>
    <input type="hidden" name="submitted" value="TRUE" />
    <input type="hidden" name="id" value="' . $id . '" />
    </form>';
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You might want to look at the PHP-processed HTML from this and see if there's any syntax errors after this processes as those variables could potentially mix things up. From the code you provided, I see no issues, but it's out of context so the issue could be elsewhere.

    You have the key pieces; an action and method on the form and the submit button is of type "submit." Is there any JavaScript on the page that could be interfering? From your browser you can open the error console and see if anything pops up.
     
  3. CANEHDN macrumors 6502a

    CANEHDN

    Joined:
    Dec 12, 2005
    Location:
    Eagle Mountain, UT
    #3
    I just copied the code you had and it works just fine for me. Below is the code straight from my page. Don't know why it's not working for you.

    UPDATE: I even used the same variables and just put random stuff there. Still works fine for me

    http://secureonlineoffers.com/dev/mike/test.php

    PHP:
    $row[0] = "asdasdasd";
    $row[1] = "asdafdfdsf";
    $row[2] = "fdfgbfg";
    $row[3] = "bgfgf";
    $row[4] = "33423";
    $row[5] = "erwr2";
    $id 123;

    echo 
    '<form action="edit_record.php" method="post">
        
    <p>Created By: <input type="text" disabled="disabled" name="created_by" size="15" maxlength="15" value="' 
    $row[0] . '" /></p>
    <p>Start Time: <input type="text" name="start_time" size="30" maxlength="20" value="' 
    $row[1] . '" /></p>
    <p>End Time: <input type="text" name="end_time" size="30" maxlength="20" value="' 
    $row[2] . '"  /> </p>
    <p>Description:<br /> <textarea rows="6" cols="40" name="description">' 
    $row[3] . '</textarea> </p>
    <p>Status: <select name="status" id="status" Value="' 
    $row[4] . '">
        <option>Open</option>
        <option>Work in Progress</option>
        <option>Cancelled</option>
        <option>Closed</option>
    </select>
    </p>
    <p>Assigned to: <input type="text" disabled="disabled" name="assigned_to" size="15" maxlength="15" value="' 
    $row[5] . '" /></p>

    <p><input type="submit" name="submit" value="Submit" /></p>
    <input type="hidden" name="submitted" value="TRUE" />
    <input type="hidden" name="id" value="' 
    $id '" />
    </form>'
    ;
     
  4. NoNameBrand macrumors 6502

    Joined:
    Nov 17, 2005
    Location:
    Halifax, Canada
    #4
    By nothing happening, do you mean that your form isn't submitted, or that it is, but your DB isn't updating?

    PS: 'value' isn't an attribute of a select element.
     
  5. 3rd Doctor thread starter macrumors member

    Joined:
    Dec 4, 2009
    #5
    I have managed to fix it, i left out and else statement in my php code, for some reason it was not showing in error log which was strange.

    Thanks for the help though guys, it helped me debug the issue knowing that the form itself was not at fault.
     

Share This Page