Answer the question
In order to leave comments, you need to log in
Problem with PHP code. Can you help?
Hello! I just started learning PHP and I have a problem with the code: it doesn't run even though it's written exactly like the example. What to do?
<?
if (!isset($cardnumber))
$m = "Введите номер карточки";
elseif ($cardnumber == "")
$m = "Ваш номер пуст!";
else
$m = "Ваш номер: $cardnumber";
?>
<html>
<head>
<title>Пример обработки ввода</title>
</head>
<body>
<h1><? echo $m?></h1>
<form action="<?echo $PHP_SELF?>" method="post">
<p>Номер карточки:
<input name="cardnumber" type="text" size="20">
</form>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
$cardnumber = $_POST['cardnumber'];
And move the first block to <body>
.
There can be many problems.
1) Replace <? with <?php on the first line, and <?php echo $PHP_SELF ?>
2) Replace all $cardnumber with $_POST["cardnumber"] (post, like get, may not turn into a normal variable). "Ваш номер: $cardnumber"
change to"Ваш номер: {$_POST['cardnumber']}"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question