1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How would I create a code for something like this?

Discussion in 'PHP' started by joliett89, Nov 28, 2015.

  1. #1
    I am familiar with php, but I've never worked on this, full time. I read like 4 good books, and I made some php modifications in Wordpress, but in general I work on other things. I would need to create a simple code, which would achieve something like this:

    I want to create an age verification page for an xxx site, and this would be redirecting people to certain model pages, which look like this:

    domain.com/model/sunny-leone-123.html or domain.com/model/kagney-linn-karter-2.html (these numbers are stored in a database, and go from 1 for the first model, to whatever number is the last one, currently I have around 1200 models there, so it is that)

    This is a copy of what I posted somewhere else:

    1) Starting ulrs will look something like this:

    domain.com/e.php?m=sunny-leone (so I will need to store everything after the equal sign in a variable I would say, and obtain it with GET, most likely)

    2) Then search for "sunny-leone" in the database, which looks like this:


    This is in table named "models" and column names are "name" and "record_num"

    The url parameter is "sunny-leone", and the record in the database would be "Sunny Leone", so I would need to make sure I will convert that to the right format or search for it in a certain way.

    After it finds "Sunny Leone", it needs to match it to the "record_num" and create a url like this:

    domain.com/model/"name"-"record_num".htmlt would contain hyphens like "sunny-leone"

    So if record number for "Sunny Leone" would be "123" the url would be looking like this:


    3) And this needs to be connected to the Yes button, as a link. People will see "Are you 18 or older"? -> They will click yes, and it needs to go to this url.

    I guess this is the best way to do it, get the model name from the entry page url, search for it in the database, construct the url from this, and make it work with the yes button.

    This seems to be fairly easy, but it is kind of hard to figure out how to do it, since I don't work on php every day. If I could get some info, this would be a lot of help.

    joliett89, Nov 28, 2015 IP
  2. javaongsan

    javaongsan Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    just post your variables to the verification page and redirect using hidden fields.
    javaongsan, Nov 29, 2015 IP
  3. joliett89

    joliett89 Active Member

    Likes Received:
    Best Answers:
    Trophy Points:
    I have the following code and it does not work, after adding the database connection and query part (everything before that is correct):

    $param=str_replace("-", " ", $param);
    echo $param; 
    if (mysqli_connect_errno()) {
      printf("Connect failed: %s\n", mysqli_connect_error());
    $query=$mysqli_query($link, "SELECT column_name FROM table_name WHERE another_column_name='$param'");
    echo $query; 
    Code (markup):
    I get the following error:

    "Connect failed: Unknown MySQL server host 'host' (20)"

    ...and the code is correct according to PhpCodeChecker.com.
    joliett89, Nov 30, 2015 IP
  4. javaongsan

    javaongsan Well-Known Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Its a straight forward database connection error.
    Your MySQL host might not be localhost
    javaongsan, Nov 30, 2015 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Seriously? You're trying to literally link to the database using 'host' as the host - instead of using $host which contains the 'localhost'... *shakes head* Fix the mysqli_connect() statement to actually use the variables you declared...
    PoPSiCLe, Nov 30, 2015 IP