5 Replies - 5288 Views - Last Post: 08 October 2012 - 02:17 PM Rate Topic: -----

#1 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 171
  • Joined: 07-October 12

Reload Original Page after submit.

Posted 08 October 2012 - 11:59 AM

I have Three Pages I would like to have talk to each other.
One is The basic index.php, when you click a link on it it will give a small pop up of content_editor.php which includes the form to update the content (Unique Name right? =D) After you submit the form it will run update_content.php
update_content.php
  <?php

$link     = mysqli_connect("$server", "$user", "$pass", "$webdb");
    $page = mysqli_real_escape_string($link, (string) $_POST['page']);
    $content = mysqli_real_escape_string($link, (string) $_POST['content']);
$query = "UPDATE `pages` 
              SET `content`='$content' 
              WHERE `name`='$page'";

    mysqli_query($link, $query);
    mysqli_close($link);

?>
 <script type='text/javascript'>
     self.close();
</script>

index_content_editor.php
<form action="update_content.php" method="post">
    <textarea name="content" cols="50" rows="10"></textarea>
    <input type="hidden" name="page" value="Index" />
    
   <br /><input type="submit" value="Update" />
   </form>

Does anybody know a way that I can get it to automatically refresh the original index.php when the submit button is clicked?

Is This A Good Question/Topic? 0
  • +

Replies To: Reload Original Page after submit.

#2 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 436
  • View blog
  • Posts: 1,851
  • Joined: 30-April 10

Re: Reload Original Page after submit.

Posted 08 October 2012 - 12:34 PM

Why did you choose to add a pop up instead of just opening the form page and submit it to its self then redirect to the index again to refresh the contents?

Because you are using a separate page to do the update and form you'll have to refresh the index page by hand or have it close when your pop up shows and redirect to it when you close the update page.

Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#3 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 171
  • Joined: 07-October 12

Re: Reload Original Page after submit.

Posted 08 October 2012 - 12:47 PM

It's an edit box that I've made and basically the user clicks the update icon and afterwards it will execute the query and then close the pop up; I've heard of javascript being used to refresh the parent page, but I have no idea how to implement it.
Was This Post Helpful? 0
  • +
  • -

#4 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 436
  • View blog
  • Posts: 1,851
  • Joined: 30-April 10

Re: Reload Original Page after submit.

Posted 08 October 2012 - 01:04 PM

opener.location.reload();
close();

Try this.
But I believe you have to make the form submit to its self for this to work but I may me wrong.
Was This Post Helpful? 1
  • +
  • -

#5 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 171
  • Joined: 07-October 12

Re: Reload Original Page after submit.

Posted 08 October 2012 - 01:29 PM

It works like a charm. Closes my popup and refreshes the parent page. :) Thanks a ton.
Was This Post Helpful? 0
  • +
  • -

#6 unum_sanctum()  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 08-October 12

Re: Reload Original Page after submit.

Posted 08 October 2012 - 02:17 PM

I can think of a few ways to solve this

Utilize the bootstrap modal window
http://twitter.githu...javascript.html

I would have the content editor popup in a modal window (preferably bootstrap's). Why?
Well because that would still allow you to pull this off with one page.
When then user submits the content from the content editor, you can submit that via
ajax (encoding it in json), and then refresh the content on page using ajax.

Or, if you don't want to do all that javascript, then as soon as the content editor
saves data, you trigger it to submit in a form. I'm assuming the content editor is a
giant TEXTAREA anyways, so this sort of hackery should be trivial.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1