Jump to content

Posting a Dynamic Text Field *RESOLVED*


pikemsu28

Recommended Posts

Sorry if this is basic, i'm very new to php and mysql.  I have a form that will be used to update registration information the user entered when registering for access to my site.  I have the information displaying using <?php echo $row_table['value'];?> in the text field.  how would i then update the form if the person changes the information and clicks the post button?
Link to comment
Share on other sites

Hello,
I'm not sure how to answer your question as I am a bit of a newb myself. I think you will need to "update" the info in the database before retreiving and showing the info in the form? Or perhaps do an if statement if you don't want to post it to the database just yet like this:

[code]<?php
if($_POST['value']) { echo $_POST['value']; } else { echo $row_table['value']; }
?>[/code]

For mysql examples, I always find this site to be a good reference:
http://www.tizag.com/mysqlTutorial/

Hope this helps inspire something!  :)
Link to comment
Share on other sites

By update the form I assume you mean UPDATE in the database? I will explain the generals, though there is more to get it working.

1.) Assign a hidden value into the form.
<input type="hidden" name="isSubmitted" value="true">

This allows you to tell if a user has clicked submit on the form.

2.) Check the value of $_GET['isSubmitted'] assuming your form method is GET.

if(isset($_GET['isSubmitted']))
{
  //Preform The MySQL Update
  $sql = "UPDATE table SET value = '" . $_GET['value'] . "' WHERE someclause LIMIT 1";
  mysql_query($sql) || die(mysql_error());
}

Again there is more to this, but this should get your started.
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.