php - How to store page url to mysql database
I know this may sound novice to some of the members of this board. I'm attempting to create a 'bookmarking' feature. Is there a way to store page urls to mysql through php? For example, the browser has a save button and when pressed the url a person is viewing is stored in mysql.
I've attempted to do this and its gone very horrible to say the least. I would greatly appreciate any feedback.
<html> <body> <form action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" method="post"> <input type="submit" value="Save" /> </form> </body> </html> <?php $url = $_GET['url']; $dbc = mysqli_connect('xxxx', 'xxxx', 'xxxx', 'xxxx') or die('Error connecting to MySQL server'); $query = "INSERT INTO xxxx (url)". "VALUES('$url')"; $result = mysqli_query($dbc, $query) or die('Error.'); mysqli_close($dbc); ?>
this is the index page for example
and then make the insert statement to your database note: this solution i wrote just to show u a very simple way to do that