Jump to content


Loading A Part Of A Page Without Refreshing

  • Please log in to reply
3 replies to this topic

#1 ChrisPHP

  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationLebanon

Posted 29 December 2012 - 08:10 PM

Hey all,

Hope your doing all fine...
Ok my next idea is that I have this page that it contains a content. Whenever i click something in menu it loads the proper page inside the content. But when I click a button with the method POST it redirects the whole page and not the content only.
I want to display if a driver is successfully added or not inside the same page!!

Code of Admin.php:

if(isset($_POST['AName']) && isset($_POST['CEOName'])&& isset($_POST['Address']) && isset($_POST['AEmail']) && isset($_POST['ATel'])){
$target = "images/"; 
$target = $target . basename( $_FILES['AImage']['name']);
$sql="INSERT INTO agence(agID,nom_loueur,adresse,email,tel,AImage)values('".$an."','".$cn."','".$a."','".$ae."','".$at."','".$file."')";

if(move_uploaded_file($_FILES['AImage']['tmp_name'], $target)){
$res=mysql_query($sql) or die(mysql_error());
header('location: ../Admin.php?add');
echo "<html><font size='4' color='white'><b>Can't insert..</b></font></html>";


and in the main page Admin.php added:

 echo "<html><center><font size='4' color='white'><b>Successfuly added!!</b></font></center></html>";

echo"<html><center><font size='4' color='white'><b>Welcome to Admin's page!!</b></font></center></html>";

I know that this way gives the result on Admin.php and not inside the content in page chosen...

Thanks in advance
Best regards,

#2 pcroarkin

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 07 January 2013 - 02:59 AM

You will need to use AJAX and DOM (document object model). Are you familiar with either? If not, the answer could be long and complicated but I will try to help.

#3 cpd

  • Members
  • PipPipPip
  • ¬_¬
  • 892 posts
  • LocationLondon, UK

Posted 07 January 2013 - 10:49 AM

I'm not sure what your definition of "driver" is but it sounds like you want to test if content is loaded?

You can use jQuery as it simplifies things - may be overkill for one task though - or alternatively write a small object to create the request etc. Can't really help other than that as you've not attempted anything.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

"One of my most productive days was throwing away 1000 lines of code."

#4 ChrisPHP

  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationLebanon

Posted 07 January 2013 - 02:49 PM

Well this topic is somehow old, i did solve my problem eventually.. I used jquery and a lot of debugging and managed to work out my idea :)
Thanks anyways :)
Best regards,

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users