Answers for "insert current url in php mysql"

PHP
0

insert current url in php mysql

<html>
  <body>
   <?php

//getURL function to get URL

function getURL()

 {

    /* First check if page is http or https */

    //$whichprotocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';

    /* Combine different pieces of $_SERVER variable to return current URL */

    //return $whichprotocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    return '://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

 }

 /*Calling getURL function to display current page URL*/


?>
<form action="something.php" method = "POST" >
  <p>		    
  <input type="hidden" name="url" id="url" value="<?php echo getURL();?>" />
  </p>
< /form>
  </body>
 </html> 
  
  /* in something.php*/
  $query = "INSERT INTO tablename (name, email, phone, category,term,url) VALUES ('$name', '$email', '$phone', '$category','$checkbox','$url')";
Posted by: Guest on March-20-2021

Browse Popular Code Answers by Language