justlukeyou Posted December 2, 2012 Share Posted December 2, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/271503-show-updates-directly-to-page/ Share on other sites More sharing options...
Pikachu2000 Posted December 2, 2012 Share Posted December 2, 2012 Look at where your SELECT queries are. Look at where your UPDATE query is. Do you think maybe the order of operations has something to do with the problem? Quote Link to comment https://forums.phpfreaks.com/topic/271503-show-updates-directly-to-page/#findComment-1397008 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.