LOLWesta, a social media forum


You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

1
Load PHP data to your forum on Sun Sep 28, 2014 1:24 am

LOLWesta


LOLWesta King
Well, guess what's my tutorial now? It's load PHP data to your forum. You can use it with CORS, or AJAX. I prefer ajax 'cause that's the simplest way.

Ok, so imagine that you want to create userdatas and store it into database. First, you create a server. I recommend you use 000webhost. Then, open your forum and open JavaScript Management.

Then you create some AJAX. You do something like :

Code:
$(function() { $.get("yourphpscript.php", function( data ) {
console.log( data );
});

Then you set header on your PHP :

Code:
header(Access-Control-Allow-Origin) : *
your php code.. continue working with php code

If there's an error origin on your console then set the header value; if *, then change it into yourforum.forumotion.com.

That's it!

View user profile http://lolwesta.forummotions.com

2
Re: Load PHP data to your forum on Mon Dec 22, 2014 2:01 pm

sugar


Members
Members
wrong syntax ?

correct one :

Code:
header(Access-Allow-Control-Origin: *);

you can either do this :

Code:
if($_SERVER['HTTP_ORIGIN'] == "somewebsite.com") {
header(Access-Allow-Control-Origin: "somewebsite.com");
}
else
{
header("HTTP/1.1 403 Access Forbidden");
echo("403 Forbidden");
}

Smile

View user profile

3
Re: Load PHP data to your forum on Sat Jan 17, 2015 11:48 am

Left


Members
Members
Don't forget this : if you'll make some script.php with mySQL needs, you have to connect the database to the script. Wink With something like.. uh, include('data.sql'); --- that's as far as I'm learning. But that will make the page load more slowly, if that's not a problem at all for you.

View user profile

Sponsored content


View previous topic View next topic Back to top Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum