Проверка на Код + Изпращане на майл с 1 клик (Php-Fusion)

daniwin

Registered
Така от доста време се чудя как тези 2 кода да ги направя на 1
става въпрос за смс услугата на мобио (Проверка на Код) та идеята е кодът получен от изпратеният смс да се попълва в 1 поле от цялата форма и ако кодът е валиден да се изпраща заявката която отива на майл адрес ако не да пренасочва на друга страница която да пише че е невалиден и тн ... ако може някой да ми ги събере 2та кода
с 2 думи "Submit" с валиден код изпращане на майла
"Submit" с невалиден пренасочване към bad.php примерно


П.С. И също така кодът въведен в полето да идва като текст на майла

Извинявам се за глупостите но просто немога да се оправя с това
:oops:


Код:
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2006 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
include LOCALE.LOCALESET."sms-admin.php";

if (isset($_POST['sendmessage'])) {
	$error = "";
	$mailname = substr(stripinput(trim($_POST['mailname'])),0,50);
	$email = substr(stripinput(trim($_POST['email'])),0,100);
	$subject = substr(str_replace(array("\r","\n","@"), "", descript(stripslash(trim($_POST['subject'])))),0,50);
	$message = descript(stripslash(trim($_POST['message'])));
	if ($mailname == "") {
		$error .= "· <span class='alt'>".$locale['420']."</span><br>\n";
	}
	if ($email == "" || !preg_match("/^[-0-9A-Z_\.]{1,50}@([-0-9A-Z_\.]+\.){1,50}([0-9A-Z]){2,4}$/i", $email)) {
		$error .= "· <span class='alt'>".$locale['421']."</span><br>\n";
	}
	if ($subject == "") {
		$error .= "· <span class='alt'>".$locale['422']."</span><br>\n";
	}
	if ($message == "") {
		$error .= "· <span class='alt'>".$locale['423']."</span><br>\n";
	}
	if (!$error) {
		require_once INCLUDES."sendmail_include.php";
		sendemail($settings['siteusername'],$settings['siteemail'],$mailname,$email,$subject,$message);
		opentable($locale['400']);
		echo "<center><br>\n".$locale['440']."<br><br>\n".$locale['441']."</center><br>\n";
		closetable();
	} else {
		opentable($locale['400']);
		echo "<center><br>\n".$locale['442']."<br><br>\n$error<br>\n".$locale['443']."</center><br>\n";
		closetable();
	}
} else {
	opentable($locale['400']);
	echo $locale['401']."<br><br>
<form name='userform' method='post' action='".FUSION_SELF."'>
<table align='center' cellpadding='0' cellspacing='0' class='tbl'>
<tr>
<td width='100'>".$locale['402']."</td>
<td><input type='text' name='mailname' maxlength='50' class='textbox' style='width: 200px;'></td>
</tr>
<tr>
<td width='100'>".$locale['403']."</td>
<td><input type='text' name='email' maxlength='100' class='textbox' style='width: 200px;'></td>
</tr>
<tr>
<td width='100'>".$locale['404']."</td>
<td><input type='text' name='subject' maxlength='50' class='textbox' style='width: 200px;'></td>
</tr>
<tr><td valign='top' width='90'>".$locale['405']."</td>
<td><textarea name='message' rows='10' cols='58' class='textbox'></textarea></td>
</tr>
<tr>
<td align='center' colspan='2'>
<input type='submit' name='sendmessage' value='".$locale['406']."' class='button'>
</td>
</tr>
</table>
</form>\n";
	closetable();
}

require_once "side_right.php";
require_once "footer.php";
?>
<script  type="text/javascript" language="javascript">var zstpagid =1;</script>

Код:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="bg">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SMS code</title>
</head>
<body>
<?PHP

function mobio_checkcode($servID, $code, $debug=0) {

	$res_lines = file("http://www.mobio.bg/code/checkcode.php?servID=$servID&code=$code");

	$ret = 0;
	if($res_lines) {

		if(strstr("PAYBG=OK", $res_lines[0])) {
			$ret = 1;
		}else{
			if($debug)
				echo $line."\n";
		}
	}else{
		if($debug)
			echo "Unable to connect to mobio.bg server.\n";
		$ret = 0;
	}

	return $ret;
}


$servID = 29;
$code = $_REQUEST["code"];
$ok = $_REQUEST["ok"];

if($ok) {
	if(mobio_checkcode($servID, $code, 0) == 1) {
		echo "Кодът е валиден!";
	}else{
		echo "Грешен или изтекъл SMS код за достъп";
	}
}else{
?>
За да получите код за достъп изпратете SMS с текст payserv на номер 2323 (цена: 1.20лв.). Кодът е с валидност 10 дни.
<form method="post" name="smscode">
Име: <input type="text" size="20" name="nick"/><br/>
SMS код: <input type="text" size="20" name="code"/><br/>
<input type="submit" name="ok" value=" Проверка "/>
</form>
<?PHP } ?>
</body>
 

Back
Горе