Answer the question
In order to leave comments, you need to log in
Can't send header?
I can't send the header, please help me, explain the width. How to get show_user.php ?
create_user.html
<form action="./scripts/create_user.php" method="POST" enctype="multipart/form-data">
<fieldset>
<label for="first_name">Имя:</label>
<input type="text" name="first_name" size="20" /><br>
<label for="last_name">Фамилия:</label>
<input type="text" name="last_name" size="20"><br>
<label for="email">Адрес электронной почты:</label>
<input type="text" name="email" size="50">
<label for="facebook_url">URL в Facebook:</label>
<input type="text" name="facebook_url" size="50">
<label for="twitter_handle">Идентификатор в Twitter:</label>
<input type="text" name="twitter_handle" size="20"><br>
<label for="bio">Биография:</label>
<textarea name="bio" cols="40" rows="10"></textarea>
</fieldset>
<br>
<fieldset class="center">
<input type="submit" value="Вступить в клуб">
<input type="reset" value="Очистить и начать все заново">
</fieldset>
</form>
<?php
require "database_connection.php";
$first_name = trim($_REQUEST['first_name']);
$last_name = trim($_REQUEST['last_name']);
$email = trim($_REQUEST['email']);
$bio = trim($_REQUEST['bio']);
$facebook_url = str_replace("facebook.org", "facebook.com", trim($_REQUEST['facebook_url']));
$position = strpos($facebook_url, "facebook.com");
if ($position === false) {
$facebook_url = "http://www.facebook.com/" . $facebook_url;
}
$twitter_handle = trim($_REQUEST['twitter_handle']);
$twitter_url = "http://www.twitter.com/";
$position = strpos($twitter_handle, "@");
if ($position === false) {
$twitter_url = $twitter_url . $twitter_handle;
} else {
$twitter_url = $twitter_url . substr($twitter_handle, $position + 1);
}
?>
<?php
$insert_sql = "INSERT INTO users (first_name, last_name, email, bio, facebook_url, twitter_handle) VALUES ('{$first_name}', '{$last_name}', '{$email}', '{$bio}', '{$facebook_url}', '{$twitter_handle}')";
mysql_query($insert_sql) or die(mysql_error());
header("Location: show_user.php");
exit();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="example">Профиль</div>
<div id="content">
<div class="user_profile">
<?php
require "database_connection.php";
// Получение ID показываемого пользователя
$user_id = $_REQUEST['user_id'];
// Создание инструкции SELECT
$select_query = "SELECT * FROM users WHERE user_id = " . $user_id;
$result = mysql_query($select_query);
if ($result) {
$row = mysql_fetch_array($result);
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$bio = $row['bio'];
$email = $row['email'];
$facebook_url = $row['facebook_url'];
$twitter_handle = $row['$twitter_handle'];
$twitter_url = "http://www.twitter.com/" . substr($twitter_handle, $position + 1);
$user_image = "creation.jpg";
} else {
die("Ошибка обнаружения пользователя с ID {$user_id}");
}
?>
<h1><?php echo "{$first_name} {$last_name}"; ?></h1>
<p>
<img src="<?php echo $user_image; ?>">
<?php echo $bio; ?>
</p>
<p>Duis irure culpa velit nostrud.</p>
<p class="contact_info">Поддерживайте свазь с <?php echo $first_name; ?></p>
<ul>
<li><a href="<?php echo $email; ?>">По Электронной почте</a></li>
<li><a href="<?php echo $facebook_url; ?>">посещение его страницы на Facebook</a></li>
<li><a href="<?php echo $twitter_url; ?>">отслеживания его сообщений в Twitter</a></li>
</ul>
</div>
</div>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
before sending headers, NOTHING should be sent to the output, that is, the first lines of the response should be headers. So either you have some kind of output before calling the header (it can be not only echo, but also a warning output) or the file itself has the wrong encoding, which causes extra characters to be output when the script starts (check that the encoding must be UTF- 8 without BOM).
Warning: Cannot modify header information - headers already sent by (output started at C:\OSPanel\domains\localhost\scripts\create_user.php:1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question