Crea sito

Submit

[insert_php]

include_once “pmg/pmg.php”;

function pmg_validate() {
global $pmg_error;
global $pmg_result;

// only logged user can submit
if (!is_user_logged_in()){
echo “You must login before to be able to submit an entry!”;
return;
}

// be sure submit is from a post
if($_POST[‘pmg_formSubmit’] == “Submit”) {
$varNumber = $_POST[‘pmg_number’];
$varValue = $_POST[‘pmg_value’];
$user_id = get_current_user_id();

// avoid to submit for 0 competition
if ($varNumber==0) {
echo “Actually there is not competition being running. Submit entry only when a competition is open. Thanks.”;
return;
}

// validate input of user
if(empty($varValue)) {
echo “You have not inserted a solution of the competition problem”;
return;
}

if (!pmg_submit($user_id, $varNumber, $varValue)) {
echo $pmg_error;
return;
}

echo “GOOD!!\n\n”;

echo $pmg_result;
} else echo “This page must be viewed after submitting a solution, not directly”;
}

pmg_validate();

[/insert_php]

Have other solutions? Go here to insert a new one!

1 vote