250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- ipad
- 비전공자
- iPhone
- javascript
- 애니메이션
- html5
- react
- Animation
- 백엔드
- 풀스택
- php
- MAC
- hover
- 자바스크립트
- SWIFT
- CSS
- 개발자
- iOS 개발자
- IOS
- front-end
- image
- effect
- keyframes
- css3
- 비전공 개발자
- button
- 프론트엔드
- HTML
- xcode
- jQuery
Archives
- Today
- Total
비전공자 개발일기
PHP curl (post) 본문
728x90
SMALL
1. 보내는 곳
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<h1 style="text-align: center;">API TEST</h1>
<form style="width: 80%; border: 1px solid; margin: 50px 175px; padding: 40px;" action="보내는곳(2).php" method="post" id="test">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">NAME</label>
<input type="text" class="form-control" name="name">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">NUMBER</label>
<input type="text" class="form-control" name="number">
</div>
<button type="submit" class="btn btn-dark" style="width: 100%;">Submit</button>
</form>
2. 보내는 곳 (2)
<?php
$method = "post";
$name = $_POST['name'];
$number = $_POST['number'];
$data = [];
$data['name'] = $name;
$data['number'] = $number;
$url = "받는 url"; // 받는 url
$url2 = "보내는 url"; // 보내는 url
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close();
$sql = "
INSERT INTO mt_test_api
(name, tel, send_name)
VALUES
('{$name}','{$number}','22222')
";
excute($sql);
print_r($result);
?>
3. 받는 곳
<?php
$name = $_POST['name'];
$number = $_POST['number'];
if(!$name) {
echo "이름 누락!<br/>";
} else if(!$number) {
echo "번호 누락!<br/>";
} else {
echo "이상 무!<br/>";
$sql = "
INSERT INTO mt_test_api
(name, tel, send_name)
VALUES
('{$name}', '{$number}', '문상우')
";
if(excute($sql) > 0 ) {
echo "테스트 이상 무!<br/>";
} else {
echo "테스트 실패!<br/>";
}
}
?>
728x90
LIST
'PHP' 카테고리의 다른 글
PHP imagecreatefrompng / ImageColorAllocate / ImageTTFText (0) | 2022.02.22 |
---|---|
Function with PHP (변수) (0) | 2022.01.03 |
WHILE, FOR, FOREACH in PHP (0) | 2022.01.02 |
SWITCH CASE with PHP (0) | 2022.01.01 |
PHP with if condition (0) | 2021.12.31 |