数字とメッセージのテキストボックスを持つフォームがあります。フォーム提出時に、私はテキストメッセージを送信するための実行可能ファイルを実行しています。私は、exeファイルと一緒に番号とメッセージであるユーザー入力を取得したい。PHPシェルコマンド実行時に引数を渡す
とここに私のフォームと私のコードです:
<?php
if($_POST['submit']){
$to = $_POST['to'];
$msg = $_POST['message'];
exec('START C:\SMS\abc.exe -Compose $to $msg');
echo "Message Sent";
}
?>
<form action="<?php echo $_SERVER['REQUEST_URI']?>" method="POST">
<label class="control-label">To:</label>
<input type="text" class="form-control" name="to">
<textarea class="inbox-editor form-control" name="message" rows="12"></textarea>
<input type="submit" class="btn blue" value="Send" id="submit" name="submit"/>
</form>
それは「$へ」と「$メッセージ」ではないテキストボックスの入力の値を読み取ります。
時間試してください:あなたがサンプルを与えることができるhttp://php.net/manual/en/language.types.string.php#language.types.string.parsing – CBroe
をコマンドラインの構文? 'exec'の代わりに –
と入力して、' die'と打ってみてください。それはメッセージを送信しませんが、文字列を出力します。それにより、実際のコマンドを見ることができます。 – Martijn