insert current url in php mysql

Solutions on MaxInterview for insert current url in php mysql by the best coders in the world

showing results for - "insert current url in php mysql"
Lucia
04 Mar 2019
1 <html>
2  <body>
3   <?php
4
5//getURL function to get URL
6
7function getURL()
8
9 {
10
11    /* First check if page is http or https */
12
13    //$whichprotocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
14
15    /* Combine different pieces of $_SERVER variable to return current URL */
16
17    //return $whichprotocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
18    return '://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
19
20 }
21
22 /*Calling getURL function to display current page URL*/
23
24
25?>
26<form action="something.php" method = "POST" >
27  <p>		    
28  <input type="hidden" name="url" id="url" value="<?php echo getURL();?>" />
29  </p>
30< /form>
31  </body>
32 </html> 
33  
34  /* in something.php*/
35  $query = "INSERT INTO tablename (name, email, phone, category,term,url) VALUES ('$name', '$email', '$phone', '$category','$checkbox','$url')";