Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Mar 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question For the love of god please...

    Here's a form, lovely isn't it.....


    PHP Code:
       <form action="send.php" method="post" >
       <
    table border="0" bgcolor="#f0f0f0" ID="Table1">
       <
    tr>
          <
    td valign="top">Recipient:</td>
          <
    td>
             <
    input size="13" type="text" name="Recipient" value="+44">
             <
    br>
             <
    font size="1" face="sans-serif"><b><font color="#700000">UK RECIPITENTS ONLY </font></b></font>      </td>
       </
    tr>
       <
    tr>
       </
    tr>
       <
    tr>
          <
    td valign="top">Message:<br>(max160 chars)</td>
          <
    td>
             <
    textarea rows="3" name="Message" cols="38"></textarea>
          </
    td>
       </
    tr>
       </
    table>
       <
    br>
       <
    input type="submit" value="Send Message">
       <
    br>
       <
    br>
       <
    b>IMPORTANT:</bPlease press the button <b>only once</b>, and allow some time for the SMS to be processed
       </
    form
    What I would like is somebody to change this so that the first field is validated by PHP - (because js can be disabled) to make sure it starts with either +44 or 07, and to make sure the second field is no more than 160 characters.

    Pretty please!!!

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    PHP Code:
    if(!(substr($_POST['recipient'],0,3)=='+44'||substr($_POST['recipient'],0,2)=='07')||strlen($_POST['message']>160) {
      die(
    "error");

    should point you in the right direction...

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Location
    Connecticut, USA
    Posts
    400
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Sorry GJay.... I believe in "give a man a fish.... teach a man to fish..." but I went and did it all, might as well post it.

    PHP Code:
    <?php
    $message 
    = array();
    $valid 1;
    if ( isset( 
    $_POST['send'] )) {
        
    $pos1 strpos$_POST['Recipient'], "+44" );
        
    $pos2 strpos$_POST['Recipient'], "07" );

        if ( 
    $pos1 !== && $pos2 !== ) {
            
    $valid 0;
            
    $message[] = "Recipient field must be either 07 or +44.";
        }
        
        if ( isset( 
    $_POST['Message'] )) {
            if ( 
    strlen$_POST['Message'] ) > 160 ) {
                
    $valid 0;
                
    $message[] = "Your message cannot exceeed 160 characters in length.";
            }
        }
        
        if ( 
    $valid ) {
            
    // success!  do something here... redirect maybe? 
            // header( "Location: /somefile.html" );
        
    }
    }
    ?>

    <html>
    <head></head>
    <body>
    <form action="" method="post" >
        <?
        
    foreach( $message as $msg ) {
            echo 
    "<span style=\"color: #990000; font-weight: bold;\">$msg</span><br/>";
        }
        
    ?>
        
       <table border="0" bgcolor="#f0f0f0" ID="Table1">
       <tr>
          <td valign="top">Recipient:</td>
          <td>
             <input size="13" type="text" name="Recipient" value="+44">
             <br>
             <font size="1" face="sans-serif"><b><font color="#700000">UK RECIPIENTS ONLY </font></b></font>      </td>
       </tr>
       <tr>
       </tr>
       <tr>
          <td valign="top">Message:<br>(max. 160 chars)</td>
          <td>
             <textarea rows="3" name="Message" cols="38"></textarea>
          </td>
       </tr>
       </table>
       <br>
       <input type="submit" name="send" value="Send Message">
       <br>
       <br>
       <b>IMPORTANT:</b> Please press the button <b>only once</b>, and allow some time for the SMS to be processed. 
       </form>  

    </body>
    </html>
    Last edited by bustamelon; 03-18-2006 at 10:21 PM.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mex
    Posts
    122
    Thanks
    0
    Thanked 0 Times in 0 Posts
    since PHP is a server side scripting language, the importat part of code here would be the php script that manages the information sent by the form you posted that would be "send.php" if you post that code we could help you do what you want, it is very easily done using if conditionals like this:

    PHP Code:
    if ((stripos($text"+44") == "0")  OR (stripos($text"07") == "0")) {  // do the rest of the script
    } else { // Tell the user his number is wrong. 


    luck
    Calilo

  • #5
    New Coder
    Join Date
    Mar 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Calilo
    since PHP is a server side scripting language, the importat part of code here would be the php script that manages the information sent by the form you posted that would be "send.php" if you post that code we could help you do what you want, it is very easily done using if conditionals like this:

    PHP Code:
    if ((stripos($text"+44") == "0")  OR (stripos($text"07") == "0")) {  // do the rest of the script
    } else { // Tell the user his number is wrong. 


    luck
    Calilo
    Thanks

    Heres send.php

    PHP Code:
    <html>
       <head>
       <META HTTP-EQUIV="CONTENT-Type" CONTENT="text/html;CHARSET=utf-8" >
       <title>Insides-Out SNS Service Status</title>
       </head>
       <body>
       <em><font face="sans-serif" size="2">   </em>
       <hr size="1" color="#707070">
       <div align="center"><em><font size="4"><strong>
         <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="503" height="30" title="title">
           <param name="movie" value="text1.swf">
           <param name="quality" value="high">
           <embed src="text1.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="503" height="30" ></embed>
         </object>
       </strong></font>
       <br>
       <br>
       </em>   </div>
       <hr size="1" color="#707070">
       <div align="center"><em><br>
         
       <?php
       
       $objSmpp 
    = new COM "ActiveXperts.Smpp" );
       
       
    $objSmpp->Server           "localhost";
       
    $objSmpp->ServerPort       =  6000;
       
    $objSmpp->SystemID         "*******";
       
    $objSmpp->SystemPassword   "*******";
       
    $objSmpp->SystemType       "SMPP";

       
    $objSmpp->MessageRecipient $_POST['Recipient'];
       
    $objSmpp->MessageData      $_POST['Message'];
       
    $objSmpp->MessageType      0;
       
    $objSmpp->Logfile          "c:\\PhpSmppLog.txt";
       
    $objSmpp->ServerTimeout    5000;
       
    $objSmpp->SystemMode       1;

       
    $objSmpp->Connect();

       if ( 
    $objSmpp->LastError == )
       {      
            
    $objSmpp->Send();
       }
        
       if ( 
    $objSmpp->LastError == )
       {
           Echo 
    "Message successfully submitted.";
       }
       else
       {
           
    $ErrorNum $objSmpp->LastError;
           
    $ErrorDes $objSmpp->GetErrorDescription $ErrorNum );

           Echo 
    "Error sending message: #$ErrorNum ($ErrorDes).";
       }
    ?>
         
       <br>
       <br>
       </em>
       </div>
       <hr size="1" color="#707070">
       </body>
    </html>
    Also the number doesn't have to be either +44 or 07 but start with those numbers it's a text message script, I'm sure you've worked out - but I don't want ppl to be able to send outisde the UK so I figure if they can't use anything but 07 and +44 to begin that won't happen.

    BTW you're all geniusus.
    Last edited by KRAK_JOE; 03-18-2006 at 08:34 PM.

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mex
    Posts
    122
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, since send.php is the script that makes the connection to the activexpers thing or sending sms and paging, i would leave that script intact, and change the form in order to make it a script, which would then send the right info to send.php.

    Bustamelon posted the answer, and a great answer actually, the only thing there to add is what to do with the info, when the uses submits the right number and message. si i would tell you just to add this, instead of where Bustamelon typed

    PHP Code:
    // success!  do something here... redirect maybe?  
            // header( "Location: /somefile.html" ); 
    Replace with this"

    PHP Code:
    include ("path/to/Send.php");
            exit; 
    this way when the user submits the right number and message the script will call send.php and pass the variables to it, then it will exit so wont continue printing the form
    So thank Bustamelon

    Luck
    Calilo

  • #7
    New Coder
    Join Date
    Mar 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, but it didn't work, no matter what the message fails to get to send.php - the path is right, and the syntax. So what now???

    PHP Code:
    <?php 
    $message 
    = array(); 
    $valid 1
    if ( isset( 
    $_POST['send'] )) { 
        
    $pos1 strpos$_POST['Recipient'], "+44" ); 
        
    $pos2 strpos$_POST['Recipient'], "07" ); 

        if ( 
    $pos1 !== && $pos2 !== ) { 
            
    $valid 0
            
    $message[] = "Recipient field must be either 07 or +44."
        } 
         
        if ( isset( 
    $_POST['Message'] )) { 
            if ( 
    strlen$_POST['Message'] ) > 160 ) { 
                
    $valid 0
                
    $message[] = "Your message cannot exceeed 160 characters in length."
            } 
        } 
         
        if ( 
    $valid ) { 
            include (
    "send.php");  
            exit;
        } 

    ?> 


    <html>
       <head>
       <META HTTP-EQUIV="CONTENT-Type" CONTENT="text/html;CHARSET=utf-8" >
       <title>Insides-Out SMS Service</title>
    </head>
       <body>
       <font face="sans-serif" size="2">
       <hr size="1" color="#707070">
       <div align="center"><font size="4"><em><strong>
         <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="364" height="30" title="title">
           <param name="movie" value="text2.swf">
           <param name="quality" value="high">
           <embed src="text2.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="364" height="30" ></embed>
         </object>
       </strong></em> </font>
         <br>
         <br>
       </div>
       <hr size="1" color="#707070">
       <br>
       <form action="send.php" method="post" >
         <div align="center">
           <table border="0" bgcolor="#f0f0f0" ID="Table1">
             <tr>
               <td valign="top">Recipient:</td>
            <td>
              <input size="13" type="text" name="Recipient" value="+44">
              <br>
              <font size="1" face="sans-serif"><b><font color="#700000">UK RECIPITENTS ONLY </font></b></font>      </td>
         </tr>
             <tr>         </tr>
             <tr>
               <td valign="top">Message:<br>(max. 160 chars)</td>
            <td>
              <textarea rows="3" name="Message" cols="38"></textarea>          </td>
         </tr>
           </table>
           <br>
           <input type="submit" value="Send Message">
           <br>
           <br>
           <b><em>IMPORTANT:</em></b><em> Please press the button <b>only once</b>, and allow some time for the SMS to be processed.</em> 
           </div>
       </form>
       <br>
       <hr size="1" color="#707070">
       <div align="center">
       </div>
       </body>
    </html>
    This is what I got is that right?

  • #8
    Regular Coder
    Join Date
    Mar 2006
    Location
    Connecticut, USA
    Posts
    400
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You need to update your form with the one I posted... I gave the submit button a name ("send") and added message reporting at the top. Basically, use my whole post, then replace the "success!" comment with the include() that Calillo posted. Got it?

  • #9
    New Coder
    Join Date
    Mar 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You guys are the ****.......cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •