Home>Support>PHP Code in Page Builder

PHP Code in Page Builder

Hi there. I am trying to insert the following code into a text widget in Page Buider:

[insert_php]
$servername = "localhost";
$username = "cobbcap";
$password = "AHO-zzpg?cO-";
$dbname = "cobbcap_wims";
$currentuser = "429600";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM Member WHERE CAPID = $currentuser";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Welcome " . $row["Rank"]. " " . $row["NameFirst"]. " " . $row["NameLast"]. "!";
}
} else {
echo "0 results";
}
$conn->close();
[/insert_php]

No matter what I do, it just displays the actual code, instead of actually running it.

URL: http://preview.cobbcap.org/members

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More