I am working on a search script and on each search result I want a report link button. I am not sure how to make one. I have looked on google for answers but cannot come up with anything. Can anyone give me an idea of what to do? or does anyone know where there is an example of this? I plan on using the link id and making a new table on mysql to send reports to. I am just looking for a basic button to send reports to mysql I am just not sure what would be the best way to do it. I have the data for the link id's I just need to be able to report it to a new table I am assuming. Any suggestions or examples are very appreciated. Thanks.
Chris,
First you will want to create that new table in your database to capture this information. Lets assume to you will have the following fields (very basic, you may want to add more): ReportId, LinkId, DateReported. ReportId is our primary key, LinkId is the ID you reference in your question and the DateReported is the server time we logged the transaction.
With this table created you are going to want to create a new php page, lets call it report-link.php. You are going to want to make this page accept a querystring variable called linkid (accessible in the $_GET[] collection). In the code of this page you will want to write a SQL query that inserts the value of the linkid parameter into the new link report table in the database (along with the date()).
On your search page you will be able to have users report an entry by clicking a link with the href of /path/to/report-link.php?linkid=<?php echo $link_id; ?>
Please note this example is very simplistic in nature, and offers no security for spamming, pleasant end user experience after they click the link, but this is the process you will want to follow in setting this feature up. After you have it working you can spruce up the experience for your users.
Related
I am creating a site and i am making a general option page for the site that include the site name, logo, social links so that i can manage them dynamically from one place without changing the links and text in all pages where i called them.
What I want is that the table i created in database, i want to have only one row in it. If someone try to add other row of data it should not be added because i have to call only one data for the site.
I hope the query is clear to all.
Thanks for your support. Help me if u can. please :)
By,
if someone try to add other row of data it should not be added
what do you mean? Are you trying to avoid unauthorized access? If yes, then you need to implement roles https://laracasts.com/discuss/channels/general-discussion/roles-and-permissions-in-laravel-5
To manage your site information, I'm sure you set a form that will be used to update the site info. And from the look of things you will only be updating that row when you hit save or update button. I don't think you will be doing full CRUD here just updating so there'll be no chance of inserting a new row of data in the db.
So three things:
you want to create a migration, seed the table with the site details accordingly. run the migration
you want to make sure the user trying to access this route is authorized to do so
you want to pre populate the site info in the form fields when the edit site info page loads and you want to save the form when the authorized user changes any of the site info
This way, there'll be no question of stopping further insertions into the db.
The title may be a bit awful as I'm really not sure how to describe what I'm trying to achieve without using lots of words.
I'm currently building an events website. This website has the option for users to create their own events which can be added to a big list of upcoming events that other users have submitted.
What I want to do is be able to have a user create an event and have the details of the event stored in an SQL database (which I've successfully done), I want to be able to then have a large list of events on a separate page the details of which are pulled from the server dynamically using PHP and SQL (I've also successfully done this). The part I am struggling with however is being able to create unique pages (or a single dynamic page) that displays a more detailed look at the event, such as age restrictions etc etc, which cannot be displayed on the big list which displays all the available events.
I figured that this could be done using a unique eventID, which is something the SQL database already includes and autoincrements with each new event entry. What I'm really not sure about is how I'd be able to pass that eventID through the link to the more detailed page so that the detailed page can be created displaying all of the details of the event.
I'm not even sure if this idea will work at all. Would having a page with a unique URL that is created on event submission that has a more in-depth look at the details of the event be a better idea? How would I go about creating unique URL webpages that correspond to each event on event submission?
I'm really not sure how I need to go about this at all, so I need some help and pointing in the right direction.
Here's a kind of TLDR:
1) Events website
2) All events on the website are displayed on a single page that has minimal detail about each event (title, date, location) BUT has a link to a page that displays the event in more detail.
3) User can select an event from the list and click on that event's unique HTML link to more detailed page
4) More detailed page displays event in more detail by pulling event's unique information from the database
Feel free to ask any questions at all as I know this probably isn't the easiest idea to get across
When creating the links from the general listing page to the detail page, simply include the id in the link. For example:
<A HREF="mysite.com/detail.php?id=3>Big Event</A>
In detail.php then, you'll find the id in $_GET['id'].
I want to recognize (with php, mysql) and save which blog entries a user has clicked. Like, I have tech entries, lifestyle entries etc. and I want to record which entries a user is interested in, so that I could provide just these entries for him!
So you know what I mean? I wonder if there are any tutorials or something.
Thanks, dartox.
When they are opening the page, just store the id of that blog entry in a table. Down the road, you can do something as simple as COUNT (*) on that table for that user, sort by category, and find out what category they're mostly interested in. You can get really complex for recommendations, but this is one of the more simpler ways of accomplishing it. Hope that helps!
I like to use www.statcounter.com
So create a page: tracker.PHP, and in it put the tracking code from statcounter (or Google analytics for that matter)
On every page with links I'd put a hidden iframe with an id="tracker" and no src just yet, :
<iframe id="tracker" style="visibility:hidden;height:0px;width:0px;" frameborder="0">
</iframe>
Then every link I'd do something like:
<a href="/some_tech_article.php"
onclick="document.getElementById('tracker').src='/tracker.php?location=techarticle';">Tech Articles
</a>
So everytime someone clicks a link, the iframe will invisibly load your tracker.php page and send any information you want to send in the URL (as a $_GET php variable)....from there you can track and save whatever information you'd like into a database or whatever.
You can use this trick to send information behind the scenes when users click things, without switching pages. I use this to track clicks, and update tables in mysql.
If you need me to give you a better example let me know!
Every user that signs up for the site is given a user id (stored in the database as User_ID), I am using userCake for the login/user management system just to clarify.
I am quite new to MySQL and PHP. I am trying to create a way so that a user can input a link into a form (I have the form created) and then it saves that to the database (new table?). How would I go about;
Creating the table structure for that.?
Posting the URL to the database.?
Retrieving all of the links associated with the User ID.?
Displaying all the users links in a list (a list just for testing)?
I have looked around for some time but can't seem to find anything that helps. All help is greatly appreciated.
i think maybe http://www.sitepoint.com/getting-started-mysql/
other resources are available, I tried "beginning database driven php website" in fav search engine and there is tons and tons of the stuff, i dont think the actual teaching etc can be done in a single post on SO and maybe you should learn to create tables, and query them with a query tool. once you got that you can then do your first php hello world app. create a hello world form then finally hook up database and start then looking at DB security etc.
I have a website and I want to make it easier for someone to change certain information being shown without them having to edit the HTML/PHP and using FTP.
At the moment I have this information in a php file which is included in the MYSQL query.
It would be a lot easier if this was done using a form, say a text field where a person can type the table name and it updates on the main page and starts displaying that table instead.
Sorry if I haven't explained this well. :(
I have a good news for you.
Every php/mysql-driven site in the world is made this exact way - to edit site contents using HTML form.
Even first PHP version name was PHP/FI, stands for Form Interpreter.
Even better, a site user doesn't have to deal with mysql - it's all being done in PHP. No need to type table names into form field - all table names already written in PHP code.
Usual PHP application being connected to just one mysql database - so, no need to choose.
As for the tables, it's being done this way: a user selects some human-readable matter, like "Latest news" and being redirected to the PHP script called, say, news.php. this script runs a query for the news table in the database and outputs some HTML formatted news highlights!
Even more, you don't even need to program! There are plenty of ready-made programs, such as Wordpress
store what you want to be editable in a mysql text field.
remove tags you dont want him to see
in the form echo the editable information in a textarea
have him edit
add tags
update the mysql
note depending on the users knowledge depends on how many tags you would like to remove/add. the less per a field the easier.
on more complicated things i like to have the person log in. if he has permission then all the editable fields have an edit button. if he clicks it it goes to a page with a form that he can use to edit that 1 field