728x90
반응형
<html>
<head> <title> 끝말잇기 </title>
</head>
<body>
<center>
<div style="border:solid 4px #A19CFF; width:600px ; height:400px ; padding:10px;">
<div>
<form method="POST" action="">
<?php
echo "<center><font size='10' color='#5853EB' face='serif'>"."끝말잇기"."<br>";
$input=$_POST['start'];
$before = $_POST['before'];
if (empty($before)){
$before=$input;
echo "<center><font size='5' color='#6798FD' face='fantasy'>".$before."<br>";
}
else {
if(preg_match("/[\xE0-\xFF][\x80-\xFF][\x80-\xFF]/", $input)){
$last=mb_substr($before,-1,1);
$first=mb_substr($input,0,1);
if ($last==$first){
$before =$before."-".$input;
echo "<center><font size='5' color='#6798FD' face='fantasy'>".$before."<br>";
}
else if ($last!=$first) {
echo "<script>alert('실패');</script>";
$before="";
}
}
else {
$last=substr($before,-1,1);
$first=substr($input,0,1);
if ($last==$first){
$before =$before."-".$input;
echo "<center><font size='5' color='#6798FD' face='fantasy'>".$before."<br>";
}
else if (($last!=$first) && empty($_COOKIE['word'])) {
echo "<script>alert('실패');</script>";
$before="";
}
}
}
?>
<input type="text" name="start"> <br>
<input type="hidden" name="before" value="<?=$before; ?>"/>
<div>
<input type="submit"/>
</div>
<div id="result">
</div>
</form>
</div>
</div>
</center>
</body>
</html>
728x90
반응형
'WEB > PHP' 카테고리의 다른 글
★ 웹사이트 제작 (php) (1) | 2023.02.16 |
---|---|
계산기 구현 (php) (0) | 2023.01.08 |
mysql과 mysqli 의 차이점 (0) | 2023.01.07 |
PHP와 MYSQL 연동하기 (0) | 2023.01.07 |
PHP 파일 업로드 & 다운로드 (0) | 2022.12.30 |