-1

I have an html website and I have this PHP Code that Send info to my database and then redirects me back to the html site.

mysqli_query($con,"INSERT INTO games (Title, Developer, releaseYear)
VALUES ('$_POST[title]','$_POST[developer]','$_POST[releaseYear]')");

mysqli_close($con);

$url = 'http://localhost/mysite/index.html';
header( "Location: $url" );

Now I have this div named searchResultBox. What I wanna do is to add a text into that div AFTER I have been redirected.

I have tried with code I have found on google but nothing has been succesful. This I found on stackoverflow.

$('#searchResultBox').append('<div>Added entry!</div>');

Any ideas? thanks

kenorb
  • 155,785
  • 88
  • 678
  • 743
Thomja
  • 259
  • 5
  • 15
  • 1
    That last bit isn't PHP. – Ignacio Vazquez-Abrams May 17 '13 at 10:42
  • 2
    **Your code is vulnerable to SQL injection attacks**. You *really* should be using [prepared statements](http://stackoverflow.com/a/60496), into which you pass your variables as parameters that do not get evaluated for SQL. If you don't know what I'm talking about, or how to fix it, read the story of [Bobby Tables](http://stackoverflow.com/q/332365). – eggyal May 17 '13 at 10:50
  • Read my edits. Hope it helps. – Maresh May 17 '13 at 10:52
  • Eggyal atleast tell me what to fix instead of just throwing it out there. Also that is off-topic, I am not using this for a site that I want to go online. It's just practice. I did'nt mention it because it was irrelevant to the question. – Thomja May 17 '13 at 15:28
  • possible duplicate of [Appending html data from a file using PHP and Jquery](http://stackoverflow.com/questions/21755968/appending-html-data-from-a-file-using-php-and-jquery) – kenorb Mar 19 '15 at 22:04

1 Answers1

-1

What you want exactly is a dynamic content, meaning: the html output changing depending on certain situations.

The code line you mentionned is jQuery, which means it's executed client side. And it is not what you need to achieve this. (Unless you use Ajax)

You need to output your HTML dynamically using PHP, with a template engine optionnaly (IMO it's cleaner).

Static HTML is not enough for what you want. I suggest you follow a tutorial, like this one for example: http://www.1stwebdesigner.com/tutorials/getting-started-php-dynamic-content/

Maresh
  • 4,644
  • 25
  • 30
  • I did not downvote you. Some retard downvoted me aswell instead of pointing to a fix. I read the link and it seems ok. Problem is that I forgott my laptop in my locker and can't get it till monday. But this page is bookmarked and I will revisit it then. Thanks – Thomja May 17 '13 at 15:30