Hirdetés
- Xiaomi 15T - reakció nélkül nincs egyensúly
- Bemutatkozott a Poco X7 és X7 Pro
- Samsung Galaxy A54 - türelemjáték
- Xiaomi 14T Pro - teljes a család?
- Samsung Galaxy A56 - megbízható középszerűség
- Milyen okostelefont vegyek?
- iPhone topik
- Külföldi prepaid SIM-ek itthon
- Garmin Instinct – küldetés teljesítve
- Fotók, videók mobillal
Új hozzászólás Aktív témák
-
válasz
lanszelot
#21060
üzenetére
Oké, megpróbáltam összedobni W3-ban, de nem jó ott a callback, viszont ez alapján látnod kellene mit kell csinálni:
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
// betöltés szimulálása
$array = array();
$array["google"] = ['kep' => "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", 'link' => "www.google.com"];
$array["startlap"] = ['kep' => "https://lap.hu/images/startlap-logo.png", 'link' => "www.lap.hu"];
// betöltés vége
// define variables and set to empty values
$nameErr = $kepErr = $linkErr = "";
$name = $kep = $link = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z_]*$/",$name)) {
$nameErr = "Only letters and underscore allowed";
}
}
if (empty($_POST["kep"])) {
$kepErr = "Email is required";
} else {
$kep = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$kep)){
$kepErr = "Invalid URL format";
$kep = "";
}
}
if (empty($_POST["link"])) {
$link = "";
} else {
$link = test_input($_POST["link"]);
// check if URL address syntax is valid (this regular expression also allows dashes in the URL)
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$link)) {
$linkErr = "Invalid URL";
$link = "";
}
}
if ($name > "" && $kep > "" && $link > "") {
$array[$name] = ['kep' => $kep, 'link' => $link];
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>PHP Form Validation Example</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Name: <input type="text" name="name" value="">
<br><br>
Kep: <input type="text" name="kep" value="">
<br><br>
Link: <input type="text" name="link" value="">
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<span class="error"><?php echo $nameErr;?></span>
<br><br>
<span class="error"><?php echo $kepErr;?></span>
<br><br>
<span class="error"><?php echo $linkErr;?></span>
<br><br>
<textarea>
<?php
var_dump($array);
?>
</textarea>
</body>
</html>
Új hozzászólás Aktív témák
- Építő/felújító topik
- Automata kávégépek
- Konkrét moderációval kapcsolatos kérdések
- GoodSpeed: Norton 360 Premium: 75GB Cloud PC Backup for 10 Devices 14.99€-ért? Igen!
- Call of Duty: Black Ops 7
- Battlefield 6
- Milyen videókártyát?
- Hardcore café
- Azonnali fáradt gőzös kérdések órája
- Fejhallgatós találkozó
- További aktív témák...
- REFURBISHED és ÚJ - HP Thunderbolt Dock G2 230W with combo cable (3TR87AA)
- Készpénzes / Utalásos Videokártya és Hardver felvásárlás! Személyesen vagy Postával!
- Eladó One Plus Nord 2T 5G 8/128GB / 12 hó jótállás
- Nintendo Switch Oled // Számal // Garancia //
- Xiaomi Redmi 13 128GB, Kártyafüggetlen, 1 Év Garanciával
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest


