@rpichioli/

PHP submitted data management

PHP (Legacy)

HTML form sending data with POST method to PHP server that read information and validate if any of them are empty.

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.44422554867820097","path":"main.php","file":{"path":"main.php","content":{"asEncoding":{"base64":"PD9waHAgCiRuYW1lID0gJyc7CiRhZ2UgPSAnJzsKJGVycm9yID0gJyc7CgovLyBTaW1wbGVzIHBvc3QgZGF0YSBtYW5hZ2VtZW50CmlmIChpc3NldCgkX1BPU1RbJ25hbWUnXSkpIHsKCgkkbmFtZSA9ICRfUE9TVFsnbmFtZSddOwoJJGFnZSA9ICRfUE9TVFsnYWdlJ107CgoJaWYgKGVtcHR5KCRuYW1lKSkgJGVycm9yID0gJ0ZpbGwgdGhlIG5hbWUuPGJyIC8+JzsKCWlmIChlbXB0eSgkYWdlKSkgJGVycm9yID0gJ0ZpbGwgdGhlIGFnZS48YnIgLz4nOwoKCS8vIFNvbWUgZHluYW1pYyBjb250ZW50IHRvIHRlc3QgSEVSRURPQyBleHByZXNzaW9uIGluIFJlcGwuaXQKCWlmIChlbXB0eSgkZXJyb3IpKSAkZXJyb3I7Cn0gCgovLyBUcnlpbmcgc29tZSBIRVJFRE9DIGJlbG93Cjw8PEhUTUwKPGh0bWw+Cgk8aGVhZD4KCQk8dGl0bGU+Rm9ybTwvdGl0bGU+Cgk8L2hlYWQ+Cgk8Ym9keT4KCQk8Zm9ybSBtZXRob2Q9InBvc3QiPgoJCQk8ZGl2PgoJCQkJPGxhYmVsIGZvcj0ibmFtZSI+TmFtZTwvbGFiZWw+CgkJCQk8aW5wdXQgdHlwZT0idGV4dCIgaWQ9Im5hbWUiIG5hbWU9Im5hbWUiIHZhbHVlPSJ7JG5hbWV9IiAvPgoJCQk8L2Rpdj4KCQkJPGRpdj4KCQkJCTxsYWJlbCBmb3I9ImFnZSI+QWdlPC9sYWJlbD4KCQkJCTxpbnB1dCB0eXBlPSJ0ZXh0IiBpZD0iYWdlIiBuYW1lPSJhZ2UiIHZhbHVlPSJ7JGFnZX0iIC8+CgkJCTwvZGl2PgoJCQk8aW5wdXQgdHlwZT0ic3VibWl0IiB0ZXh0PSJTZW5kIiAvPgoJCTwvZm9ybT4KCgkJeyFlbXB0eSgkZXJyb3IpID8gJGVycm9yIDogJ0V2ZXJ5dGhpbmcgT0shJ30KCTwvYm9keT4KPC9odG1sPgpIVE1MOwo/Pg=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php 
$name = '';
$age = '';
$error = '';

// Simples post data management
if (isset($_POST['name'])) {

	$name = $_POST['name'];
	$age = $_POST['age'];

	if (empty($name)) $error = 'Fill the name.<br />';
	if (empty($age)) $error = 'Fill the age.<br />';

	// Some dynamic content to test HEREDOC expression in Repl.it
	if (empty($error)) $error;
} 

// Trying some HEREDOC below
<<<HTML
<html>
	<head>
		<title>Form</title>
	</head>
	<body>
		<form method="post">
			<div>
				<label for="name">Name</label>
				<input type="text" id="name" name="name" value="{$name}" />
			</div>
			<div>
				<label for="age">Age</label>
				<input type="text" id="age" name="age" value="{$age}" />
			</div>
			<input type="submit" text="Send" />
		</form>

		{!empty($error) ? $error : 'Everything OK!'}
	</body>
</html>
HTML;
?>
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7