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:

    http://prntscr.com/982yph

    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:

    domain.com/model/sunny-leone-123.html

    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.

    Thanks.
     
    joliett89, Nov 28, 2015 IP
  2. javaongsan

    javaongsan Well-Known Member

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #2
    just post your variables to the verification page and redirect using hidden fields.
     
    javaongsan, Nov 29, 2015 IP
  3. joliett89

    joliett89 Active Member

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

    
    <?php
    $param=$_GET['m'];
    $param=str_replace("-", " ", $param);
    $param=ucwords($param); 
    echo $param; 
    $host="localhost";
    $username="user_name";
    $password="password_here";
    $database_name="database_name_here";
    $link=mysqli_connect('host','username','password','database_name');
    if (mysqli_connect_errno()) {
      printf("Connect failed: %s\n", mysqli_connect_error());
      exit();
    }
    $query=$mysqli_query($link, "SELECT column_name FROM table_name WHERE another_column_name='$param'");
    echo $query; 
    mysqli_close($link);
    ?>
    
    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

    Messages:
    1,054
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Its a straight forward database connection error.
    Your MySQL host might not be localhost
     
    javaongsan, Nov 30, 2015 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    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