Jump to content

Recommended Posts

Hi,

 

I have an update code which updates the database fine however when I the click the submit button it does not update the page. So if someone makes one update and then decides to make another update the first updates are deleted and replaced by the original text.

 

Do I need to reload the page or use some other method to reflect the changes directly to the page?

 

Currently I need to enter the changes twice for them to reflect on the page.

 

<div class="container">
<div class="content-container1">
 <div class="content-container2">
<div class="section-navigation">
  </div>
  <div class="content">

   <div class="topheader"> 
 <?php
$query = "SELECT * FROM users WHERE id = " . intval($_SESSION['userID']) . " LIMIT 1";
if ($result = mysql_query($query)) {

		    $row = mysql_fetch_array($result);
}
		    ?>	


 <?php
  if ($_SESSION['userLoggedIn'])
{
 echo '
  <div class="loggedinout">
 <a href="/test/closesession.php">Logout</a>
   </div>
   <div class="updateprofile">
  <a href="/test/update.php">Update Your Profile</a>
   </div>
 <div class="loggedin">
' . $row['firstname'] . ' ' . $row['surname'] . '  
 </div>
 ';
} else { echo
'<div class="headersignin">
<a href="/users/login.php"   rel="nofollow" class="blacklink"   >
Sign in
</a>
</div>
<div class="headerjoin">
<a href="/users/register.php" rel="nofollow" class="whitelink"   >Join free</a>
</div>';
}
?>


<?php
$query = "SELECT * FROM users WHERE id = " . intval($_SESSION['userID']) . " LIMIT 1";
if ($result = mysql_query($query)) {

		    $row = mysql_fetch_array($result);
 {
		    ?> 

  <div class="headerlinkright">
 <a href="/siteinfo/aboutus.php"   rel="nofollow" class='bloglink'   >About Us</a>
</div>
  <div class="headerlinkright">
<a href="/blog/blog.php"   rel="nofollow" class='bloglink'   >Blog</a>
</div>
  </div>






<div class="header">
<div class="headerlogo">
<a href="http://website.com"  rel="nofollow" >
<img src="/images/logo.png" alt="website.com"/>
</a>
</div>
<div class="internalheaderlinks">
<div class="homepagesearchformcell">
<form action="/test/searchresults.php" method="post">
<input type="text" name="keywords" placeholder='perform a search...' class="internalsearch" />
</form>
</div>
<div class="internalsearchimagecell">
<input type="image"  value="Submit" src="/images/internalsearch.png" alt="Search" name="image" />
</div>
</div>
</div>

</div>
</div>
 </div>

<div class="content-container1">
 <div class="content-container2">
<div class="section-navigation">
  </div>
  <div class="content">



<?php
function mysql_real_escape_array($t)
{
   return array_map("mysql_real_escape_string",$t);
}
function trim_array($ar)
{
   return array_map("trim",$ar);
}
if(isset($_POST['form_id']))
{
   $_POST = mysql_real_escape_array($_POST);
   $_POST = trim_array($_POST);
   $error = "";

   if($error == "")
   {
    $sql = "
    UPDATE
	    users
    SET
	    category = '".$_POST['category']."',
 linkcategory = '".str_replace(' ', '-',strtolower($_POST['category']))."',
	    firstname = '".$_POST['firstname']."',
	    surname = '".$_POST['surname']."',
	    email = '".$_POST['email']."',
	    website = '".$_POST['website']."',
	    company = '".$_POST['company']."',
	    building = '".$_POST['building']."',
	    streetname = '".$_POST['streetname']."',
  town = '".$_POST['town']."',
	    state = '".$_POST['state']."',
	    postcode = '".$_POST['postcode']."',
	    aboutcompany = '".$_POST['aboutcompany']."',
  country = '".$_POST['country']."'";
    $result = mysql_query($sql) or die("An error occurred ".mysql_error());

   }
}
?>

<div class="registerinfopagecell">
<form class="form_id"  class="appnitro"  method="post" action="">



  <div class="registerpageheaderorganiser">
Update Your Host Profile
</div>


<?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?>
<ul >


<div class="forminputcell">
<div class="datainput">
<li class="li_1" >
 <div class="forminputleft">
Your Job Role:
</div>
 <div class="forminputright">
<select  class="field"  name="category">
 <option value="<?php echo (!empty($row['category'])) ? $row['category'] : ''; ?>" selected="selected"><?php echo (!empty($row['category'])) ? $row['category'] : ''; ?></option>
   <option value="Brand Marketer" >Brand Marketer</option>
   <option value="Entertainment Promoter" >Entertainment Promoter</option>
   <option value="Event Manager" >Event Manager</option>
   <option value="Event Organiser" >Event Organiser</option>
   <option value="Party Planner" >Party Planner</option>
   <option value="Wedding Organiser" >Wedding Organiser</option>
</select>
</div>
</li>
</div>
</div>

Link to comment
https://forums.phpfreaks.com/topic/271503-show-updates-directly-to-page/
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.