Jump to content

need help with php webpage and form on webpage!


marbles

Recommended Posts

recently signed up for a text messageing service that can use php script to send required details to specific mobile numbers,

Anyways i recieved this code from the company:

 

Send Using PHP

 

<?php

//set up variables

$info = "1";

$address = "www.txtlocal.com/sendsmspost.php";

$message = "Hello this is a test with an ampersand (&) and a £5 note";

$message = urlencode($message); //encode special characters (e.g. £,& etc)

$from = "Jims Autos";

$uname = "youremailaddress";

$pword = "yourpassword";

$selectednums = "447740101098";

 

//build url

$data = "uname=" . $uname . "&pword=" . $pword . "&message=" . $message . "&from=" . $from . "&selectednums=" . $selectednums . "&info=" . $info;

 

//send messages

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"https://$address");

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec ($ch);

curl_close ($ch);

?>

 

The areas of code that i have underlined above are the values that i wish to enter via a webbased form.

 

Please help i have been trying all day using bits of codes from different websites but have had no joy!

 

 

 

on your form page use this code:

 

<form method="POST" action="http://www.txtlocal.com/sendsmspost.php">
  <input type="text" name="usermessage" size="20"><br>
  <input type="text" name="userselectednums" size="20"><input type="submit" value="Submit" name="B1"><br>
</form>

 

 

on the code you posted change the following:

 

$message = ($usermessage);

$selectednums = ($userselectednums);

 

 

that should do it. let me know how it comes out.

You can by using ISSET, but for debugging purposes I would keep them as separate pages.  Or you can pu the vendor supplied code into a .inc file and call it when needed... this way if you want to use on various pages in your site, you can just change the .inc file one time and your done.

its not working man.

Heres my code from start to finish for the form page: (PS....SHOULD I SAVE THIS as .HTM or .PHP)

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Untitled Document</title>

</head>

 

<body>

<form method="POST" action="http://www.txtlocal.com/sendsmspost.php">

  <input type="text" name="usermessage" size="20"><br>

  <input type="text" name="userselectednums" size="20"><input type="submit" value="Submit" name="B1"><br>

</form>

</body>

</html>

 

My PHP code looks like this in full:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Untitled Document</title>

</head>

<?php

//set up variables

$info = "1";

$address = "www.txtlocal.com/sendsmspost.php";

$message = ($usermessage);

$from = "watersideCU";

$uname = "ihavemyusernamehere";

$pword = "ihavemypasswordhere";

$selectednums = ($userselectednums);

 

 

 

 

//build url

$data = "uname=" . $uname . "&pword=" . $pword . "&message=" . $message . "&from=" . $from . "&selectednums=" . $selectednums . "&info=" . $info;

 

//send messages

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"https://$address");

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec ($ch);

curl_close ($ch);

?>

 

 

<body>

 

</body>

</html>

 

 

I can see one problem with it how does my form page know to relate to my php page?

 

Please help!!!!!!!!

the complete php script need only be...

 

<?php

  $info = "1";
  $address = "www.txtlocal.com/sendsmspost.php";
  $message = ($_POST['usermessage']);
  $from = "watersideCU";
  $uname = "ihavemyusernamehere";
  $pword = "ihavemypasswordhere";
  $selectednums = ($_POST['userselectednums']);
  $data = "uname=" . $uname . "&pword=" . $pword . "&message=" . $message . "&from=" . $from . "&selectednums=" . $selectednums . "&info=" . $info;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,"https://$address");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_exec ($ch);
  curl_close ($ch);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.