Jump to content

Recommended Posts

I need help on updating two fields from a MySQL database through the use of a form

I need it to update the heading field, and information field

but all it does is add a new field  Can someone please help me :)

 

This is for the form

<form id="form1" name="form1" method="post" action="pageupdate.php">
  <label>
  <input type="radio" name="radio" id="mainpage" value="mainpage" />
  Main Page   </label>
  <label>
  <input type="radio" name="radio" id="ourmission" value="ourmission" />
  Our Mission Page
     
  <input type="radio" name="radio" id="contactus" value="contactus" />
  Contact Us Page</label>
  <p>Heading:<br />
    <input name="heading" type="text" id="heading" size="50" />
  </p>
  <p>Information:   <br />
    <textarea name="information" cols="60" rows="20" id="information"></textarea>
  </p>
  <p>
    <input type="submit" name="Submit" value="Edit Page" />
  </p>
</form>

 

This is for the php update

<?php

$heading = $_POST['heading'];
$information = $_POST['information'];
$radio = $_POST['radio'];

include('dbconnect.php');

mysql_query("INSERT INTO $radio (heading,information) VALUES ('$heading','$information')");


?>

Link to comment
https://forums.phpfreaks.com/topic/52154-php-mysql-update-2-fields/
Share on other sites

I figured it out Thanks guys :)

<?php

$heading = $_POST['heading'];
$information = $_POST['information'];
$radio = $_POST['radio'];

include('dbconnect.php');

mysql_query("UPDATE $radio SET heading = '$heading' WHERE heading = heading");
mysql_query("UPDATE $radio SET information = '$information' WHERE information = information");


?>

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.