title: Raspberry PI Send Data to PHP Script through URL
body: <p>I'm working on a project for fun. I need to send data to my PHP Script which will write it to a MySQL database using MySQLi. My Raspberry PI needs to send data to the script through a url when a tracked input pin receives an on signal.</p>
  
  <p>Python Code:</p>
  
  <pre><code>import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
  
  def button_callback1(channel):
      print("Left(07) energized.")
  
  def button_callback2(channel):
      print("Right(13) energized.")
  
  GPIO.setwarnings(False) # Ignore warning for now
  GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
  
  GPIO.setup(07, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 07 to be an input pin and set initial value to be pulled low (off)
  GPIO.add_event_detect(07,GPIO.RISING,callback=button_callback1) # Setup event on pin 07 rising edge
  
  GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 13 to be an input pin and set initial value to be pulled low (off)
  GPIO.add_event_detect(13,GPIO.RISING,callback=button_callback2) # Setup event on pin 13 rising edge
  
  message = input("Press enter to quit\n\n") # Run until someone presses enter
  GPIO.cleanup() # Clean up
  </code></pre>
  
  <p>In my callback I need to send data to "localhost/datagrab.php" in the format "<strong>localhost/datagrab.php?pin=<em>#PIN#</em>&amp;status=1</strong>" whenever a pin is energized.</p>
  
  <p>I plan to expand on this further in the future and have the python script visit the same link and pass the variable status as 0 if there is no on signal within 15 seconds.</p>
  
  <p>Please put me in the correct direction</p>
  
  <p>Thanks</p>
  
  <p>Sam</p>