Jump to content

HTML FORM processed with PHP


emzz

Recommended Posts

index.php

<HTML>

<HEAD><TITLE>Send SMS</TITLE></HEAD>

<BODY>

<form method="post" action="sent.php">

<table border="1">

<tr>

<td>Mobile Number:</td>

<td><input type="text" name="phone" size="40"></td>

</tr>

<tr>

<td valign="top">Text Message:</td>

<td><textarea name="text" cols="80" rows="10"></textarea>

</tr>

<tr>

<td colspan="2" align="center">

<input type="submit" value="Send">

</td>

</tr>

</table>

</form>

</BODY>

</HTML>

 

sent.php

<?php

 

function SendSMS ($host, $port, $username, $password, $phoneNoRecip, $msgText) {

 

    $fp = fsockopen($host, $port, $errno, $errstr);

    if (!$fp) {

        echo "errno: $errno \n";

        echo "errstr: $errstr\n";

        return $result;

    }

   

    fwrite($fp, "GET /?Phone=" . rawurlencode($phoneNoRecip) . "&Text=" . rawurlencode($msgText) ." HTTP/1.0\n");

    if ($username != "") {

      $auth = $username . ":" . $password;

      $auth = base64_encode($auth);

      fwrite($fp, "Authorization: Basic " . $auth . "\n");

    }

    fwrite($fp, "\n");

 

    $res = "";

 

    while(!feof($fp)) {

        $res .= fread($fp,1);

    }

    fclose($fp);

   

 

    return $res;

}

 

if (isset($_REQUEST['phone'])) {

  if (isset($_REQUEST['text'])) {

      $x = SendSMS("192.168.10.12", 8808, "user", "password", $_REQUEST['phone'], $_REQUEST['text']);

      echo $x;

  }

  else {

      echo "ERROR : Message not sent -- Text parameter is missing!\r\n";

  }

}

else {

  echo "ERROR : Message not sent -- Phone parameter is missing!\r\n";

}

 

 

 

?> So when user submits the form i want to add a pre text after users message

Link to comment
Share on other sites

I don't think I can simplify how to add text to the end of other text any more than that.

If you're that new, rather than attempting something complicated, and using other people's code, read tutorials and learn yourself, do small projects, and work up to something involving texting.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.