Hi All. i AM USING xwd6 and made a placeholder for a search window. After inserting the code, the code became visible to the visitors. What's wrong here? Any ideas?
Hi All. i AM USING xwd6 and made a placeholder for a search window. After inserting the code, the code became visible to the visitors. What's wrong here? Any ideas?
Señor, are you sure you have the full code inserted, with < and /> terminations, etc? Does it work OK if you use it away from XWD6, like in Front Page?
I guess we'd need some more details, maybe sample code to play with...
<div id="radio_search">
<h3>Find Adventist Radio Near You</h3>
<?php
if (isset($_POST['search'])) {
$postcode = isset($_POST['postcode']) ? (int)$_POST['postcode'] : "";
if ($postcode != "") {
// Select city, state, postcode, and station where postcode = postcode entered.
/* @$conn = new mysqli('h50mysql109.secureserver.net', 'xxxxxxx', 'xxxxxxxx', 'xxxxxxxxx');
if (mysqli_connect_errno()) {
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
$query = "SELECT city, state, postcode, station FROM stations
WHERE postcode={$postcode}";
$result = $conn->query($query);
$num_results = $result->num_rows;
if ($num_results != 0) {
// If found display
for ($i=0; $i < $num_results; $i++) {
$row = $result->fetch_assoc();
echo "<p>Start listening to Adventist radio in <strong>" . htmlspecialchars(stripslashes($row['city']))
. ", " . htmlspecialchars(stripslashes($row['state'])) . "</strong> on <strong>" .
htmlspecialchars(stripslashes($row['station'])) . " FM</strong> right now!</p>";
}
} else {
echo "<p>Sorry there is no adventist radio in you area. Want to change
that? <a href=\"contact.html\">Contact us</a> to find out how.</p>";
} */
$connection = mysql_connect('h50mysql109.secureserver.net', 'xxxxxxxxx', 'xxxxxxxxxxx');
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('adventistradio', $connection);
# Check If Record Exists
$query = "SELECT city, state, postcode, station FROM stations
WHERE postcode={$postcode}";
$result = mysql_query($query);
if (mysql_num_rows($result) <= 0) {
echo "<p>Sorry there is no adventist radio in you area. Want to change
that? <a href=\"contact.html\">Contact us</a> to find out how.</p>";
} else {
while($row = mysql_fetch_array($result)) {
echo "<p>Start listening to Adventist radio in <strong>" . htmlspecialchars(stripslashes($row['city']))
. ", " . htmlspecialchars(stripslashes($row['state'])) . "</strong> on <strong>" .
htmlspecialchars(stripslashes($row['station'])) . " FM</strong> right now!</p>";
}
}
} else {
echo "<p>You must enter a valid 4 digit postcode.</p>";
}
}
?>
<form action="index.php#radio_search" method="post">
<div>
<label for="postcode">Enter Postcode: </label>
<input type="text" name="postcode" id="postcode" value="" />
<input type="submit" name="search" value="Search" />
</div>
</form>
</div>
The code looks good. Is PHP running on the server ?
Tutorials: The Basics of Web Design - Tips and Tricks - Creating a Nav Bar - Video Tutorials - Stretchy Buttons - Manual Nav Bars
I think the page in which the code is inserted needs to have a .php extension.
JOHN -XaReg (FB) XaReg (DB - ignore prompt to register)
Windows 10 [Anniversary] pro Intel Pentium CPU G630 @ 2.70Ghz RAM: 4 GB; 64-bit x64
By default only files that have a PHP extension will be parsed for PHP code but the server can be set up to parse other extensions such as HTM HTML SHTML etc.
Tutorials: The Basics of Web Design - Tips and Tricks - Creating a Nav Bar - Video Tutorials - Stretchy Buttons - Manual Nav Bars
Bookmarks