Jump to content

I think I'll snap my keyboard.


livethedead

Recommended Posts

Alright I've racked my brain over and over, and to me it seems completely illogical that this isn't fucking working. At this point I'm starting to get angry and I really need someone to explain to me why this doesn't work because I refuse to move on in my studies until I figure this out. I would really appreciate it. note: I didn't post this in regex because it's nothing to do with the regex really.

 

 

Everything works just golden except the last if statement. If I enter say "a"" in the facebook form, it will return "a", instead of: "facebook.com/a". I seriously cannot fathom why and need help. I've tried else, elseif, if in varying orders thinking maybe I just lack understanding of them but no. So that's why I have it currently placed idioticly in 3 if statements.

 

<?php
$first_name = trim($_REQUEST['first_name']);
$last_name =  trim($_REQUEST['last_name']);
$email = trim($_REQUEST['email']);

$facebook_url = trim($_REQUEST['facebook_url']);
$facebook_url_check = false;
if (preg_match("/facebook.com\/|facebook.org\/|facebook.net\//", $facebook_url)) {
	$facebook_url_check = true;
}

if ($facebook_url_check = true) {
	$facebook = preg_replace("/facebook.org\/|facebook.net\//i", 
	"facebook.com/", $facebook_url);
}
if ($facebook_url_check = false) {
		$url = "facebook.com/";
		$facebook = $url . $facebook_url;
	}
?>

Link to comment
https://forums.phpfreaks.com/topic/256988-i-think-ill-snap-my-keyboard/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.