Jump to content

Conditional Display Issue


strategos

Recommended Posts

Hello, this is my first PHP project, and I am having issues getting it to correctly display an error ONLY if the input is an error

It displays the error upon first load of the page w/o pressing submit. How would I use

isset($_POST['submit'])

to fix it?

 

<?php

$inputid = $_POST['steamid'];

$steam_prefix = substr($inputid, 0, 10);

$prefix_length = 10;

$char_total = strlen($inputid);

$steam_suffixchars = ($char_total - $prefix_length);

$suffix_check = substr($inputid, 10, $steam_suffixchars);

$class_set = "notranslate";

$is_submit = isset($_POST['submit']);

if(is_numeric($suffix_check) == true)
$suffix_valid = true;
elseif(is_int($suffix_check) == false)
$suffix_valid = false;

if($char_total > 25 || $char_total < 11)
$char_valid = false;
else
$char_valid = true;


if($steam_prefix === "STEAM_0:1:" || $steam_prefix === "STEAM_0:0:")
$prefix_check = true;
elseif($steam_prefix != "STEAM_0:1:" || $steam_prefix != "STEAM_0:0:")
$prefix_check = false;

if (preg_match('/^[A-Z0-9-:]+$/', $inputid))
$chars_matched = true;
else
$chars_matched = false;

if($suffix_check == true && $prefix_check == true && $char_valid == true && $chars_matched == true)
echo "Approved!";
elseif(isset($_POST['anon']))
echo "Approved!";
else
echo "error!";




?>

Link to comment
https://forums.phpfreaks.com/topic/255502-conditional-display-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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